summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-04-22 17:50:52 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-04-22 17:50:52 +0200
commit64efcb0fd8afe3bd208e509b9eca0f227be6edb2 (patch)
treef037cc065da3f673264ff68cf9a1e9f8b6ffc980 /modules
parentdbc091688f1edbbffb8c70e29778a9437b2d0e47 (diff)
downloadcurunir-64efcb0fd8afe3bd208e509b9eca0f227be6edb2.tar
curunir-64efcb0fd8afe3bd208e509b9eca0f227be6edb2.zip
Print new topic on change
Diffstat (limited to 'modules')
-rw-r--r--modules/topic.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/modules/topic.py b/modules/topic.py
index 7f4ca10..bdc5143 100644
--- a/modules/topic.py
+++ b/modules/topic.py
@@ -14,19 +14,22 @@ class Module(ModuleBase):
('!topic d[el[ete]] <ID>', 'Entfernt das Topic mit der ID')
]
+ def _reply_topic(self, handler, prefix):
+ topic = handler.get_topic()
+ if topic is None or topic == '':
+ handler.reply('Es ist kein Topic gesetzt.')
+ return
+ topics = [s.strip() for s in topic.split('|')]
+ idtopics = zip(range(len(topics)), topics)
+ idtopicstrings = ["%i: %s" % t for t in idtopics]
+ handler.reply(prefix + '\n\n' + '\n'.join(idtopicstrings))
+
def groupchat(self, room, nick, text, handler):
if not re.match(r'!topic(?:\s|\Z)', text):
return
if re.match(r'!topic(?:\s+(?:s(?:how)?)?\s*)?\Z', text):
- topic = handler.get_topic()
- if topic is None or topic == '':
- handler.reply('Es ist kein Topic gesetzt.')
- return
- topics = [s.strip() for s in topic.split('|')]
- idtopics = zip(range(len(topics)), topics)
- idtopicstrings = ["%i: %s" % t for t in idtopics]
- handler.reply('Aktuelles Topic:\n\n' + '\n'.join(idtopicstrings))
+ self._reply_topic(handler, 'Aktuelles Topic:')
return
oldtopic = handler.get_topic()
@@ -40,6 +43,7 @@ class Module(ModuleBase):
topic += ' | ' + oldtopic
handler.set_topic(topic)
+ self._reply_topic(handler, 'Neues Topic:')
return
if re.match(r'!topic\s+d(?:el(?:ete)?)?\s', text):
@@ -55,3 +59,4 @@ class Module(ModuleBase):
del topics[topicid]
handler.set_topic(' | '.join(topics))
+ self._reply_topic(handler, 'Neues Topic:')