summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
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:')