this runs with a basic model and even more basic test, but I'm not committing those yet as I'm still playing with the model (lest I make 30 revisions right off the bat) Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
32 lines
869 B
Python
32 lines
869 B
Python
"""Echo given string back to the user/channel."""
|
|
|
|
import logging
|
|
|
|
from ircbot.lib import Plugin
|
|
|
|
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)
|
|
|
|
super(Echo, self).start()
|
|
|
|
def stop(self):
|
|
"""Tear down handlers."""
|
|
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], self.handle_echo)
|
|
|
|
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
|