Print new topic on change
This commit is contained in:
parent
dbc091688f
commit
64efcb0fd8
1 changed files with 13 additions and 8 deletions
|
@ -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:')
|
||||
|
|
Reference in a new issue