This repository has been archived on 2025-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
curunir/modules/topic.py

30 lines
837 B
Python
Raw Normal View History

2010-05-02 23:40:21 +02:00
# -*- coding: utf-8 -*-
from base import ModuleBase
import re
class Module(ModuleBase):
def __init__(self, manager):
ModuleBase.__init__(self, manager)
def commands(self):
2010-05-06 22:10:50 +02:00
return [('!topic [<Topic>]', 'Fügt einen Text zum Thema des Chatraums hinzu oder zeigt das aktuelle Topic an')]
2010-05-02 23:40:21 +02:00
def groupchat(self, room, nick, text, handler):
2010-05-06 22:10:50 +02:00
if not re.match(r'!topic(?:\W|\Z)', text):
return
2010-05-02 23:40:21 +02:00
if not re.match(r'!topic\W', text):
2010-05-06 22:10:50 +02:00
handler.reply(handler.get_topic())
2010-05-02 23:40:21 +02:00
return
topic = re.sub(r'!topic\W+', '', text)
if topic == '':
return
oldtopic = handler.get_topic()
if oldtopic != '' and oldtopic != None:
topic += ' | ' + oldtopic
handler.set_topic(topic)