add plugin for topic update with status

This commit is contained in:
Morris Jobke 2014-04-05 12:27:28 +02:00
parent 9421d8160d
commit 63fc042027
1 changed files with 20 additions and 0 deletions

20
plugins/status.py Normal file
View File

@ -0,0 +1,20 @@
from util import hook
import re
@hook.event("TOPIC")
def topic_update(info, conn=None, chan=None):
"""topic_update -- adds status to topic"""
# retrieve current status
status = 'Offen'
topic = info[1]
if 'Status' in topic:
new_topic = re.sub('Status: \w*', 'Status: {}'.format(status), topic)
else:
new_topic = topic.rstrip(' |') + ' | Status: {}'.format(status)
if new_topic != topic:
out = "TOPIC {} :{}".format(chan, new_topic)
conn.send(out)