dr.botzo/ircbot/ircplugins/echo.py

32 lines
869 B
Python
Raw Normal View History

"""Echo given string back to the user/channel."""
2015-05-15 18:22:13 -05:00
import logging
2015-05-15 18:22:13 -05:00
from ircbot.lib import Plugin
2015-05-15 18:22:13 -05:00
log = logging.getLogger('ircbot.lib')
class Echo(Plugin):
"""Have IRC commands to do IRC things (join channels, quit, etc.)."""
def start(self):
"""Set up the handlers."""
self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], r'^!echo\s+(.*)$',
self.handle_echo, -20)
2015-05-15 18:22:13 -05:00
super(Echo, self).start()
def stop(self):
"""Tear down handlers."""
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], self.handle_echo)
2015-05-15 18:22:13 -05:00
super(Echo, self).stop()
def handle_echo(self, connection, event, match):
"""Handle the echo command... by echoing."""
return self.bot.reply(event, match.group(1))
plugin = Echo