info = { 'author': 'Jon Bergli Heier', 'title': 'IRC Quotes', 'description': 'Allows users to access a quote database.', } import sys sys.path.insert(0, '/home/snakebite/py') from quotelib import IRCHandler as Quote_IRCHandler quote_handler = Quote_IRCHandler() class Module: def __init__(self, bot): self.irc = bot def __call__(self, nick, channel, msg): if not msg.startswith('!quote'): return args = msg.split(' ') if msg.startswith('!quote'): args = args[1:] cmd = args[0] if len(args) and len(args[0].strip()) else 'random' args = args[1:] if cmd.isdigit() or (cmd[0] == '#' and cmd[1:].isdigit()): cmd, args = 'get', [cmd] quote_handler.nick = nick.split('!')[0] if hasattr(quote_handler, cmd) and callable(getattr(quote_handler, cmd)): for line in getattr(quote_handler, cmd)(*args): self.irc.msg(channel if not channel == self.irc.nickname else nick.split('!')[0], line) else: self.irc.msg(channel if not channel == self.irc.nickname else nick.split('!')[0], '%s, invalid command "%s"' % (nick.split('!')[0], cmd))