#!/usr/bin/python """ SuwBot - A Basic Suw-Oriented IRC Bot License: GPL 2; share and enjoy! Authors: Sean B. Palmer, inamidst.com Suw Charman, suwcharman.getfluent.co.uk Requirements: http://inamidst.com/proj/suwbot/ircbot.py """ import shelve import ircbot nickname = 'SuwBot' karma = shelve.open('karma') def suwbot(host, port, channels, nick=nickname): p = ircbot.Bot(nick=nick, channels=channels) def f_hi(m, origin, (cmd, channel), text, p=p): p.msg(origin.sender, 'hi %s' % origin.nick) p.rule(f_hi, 'hi', r"(?i)^(Hi|Hey|Hello|Yo)( there)?,? %s!?$" % p.nick) def f_hug(m, origin, (cmd, channel), text, p=p): try: target = m.group(1) except: target = None if (not target) or (target == "me"): target = origin.nick elif target.startswith("me "): target = origin.nick + target[2:] p.msg(origin.sender, ircbot.me('hugs %s' % target)) p.rule(f_hug, 'hug', r"(?i)^hug (.*)$") p.bind(f_hug, 'PRIVMSG', r'^.?ACTION hugs (?:.*).$') p.bind(f_hug, 'PRIVMSG', r'^.?ACTION needs a hug.?$') def f_kiss(m, origin, (cmd, channel), text, p=p): try: target = m.group(1) except: target = None if (not target) or (target == "me"): target = origin.nick elif target.startswith("me "): target = origin.nick + target[2:] p.msg(origin.sender, ircbot.me('kisses %s' % target)) p.rule(f_kiss, 'kiss', r"(?i)^kiss (.*)$") p.bind(f_kiss, 'PRIVMSG', r'^.?ACTION kisses (?:.*).$') p.bind(f_kiss, 'PRIVMSG', r'^.?ACTION wants a kiss.?$') def f_bye(m, origin, (cmd, channel), text, p=p): try: target = m.group(1) except: target = None target = target or origin.nick p.msg(origin.sender, "t'ra %s!" % target) p.bind(f_bye, 'PRIVMSG', r"(?i)^t'ra!$") def f_greet(m, origin, args, text, p=p): if origin.nick == p.nick: return p.msg('#suwcharman', '%s!' % origin.nick) p.bind(f_greet, 'JOIN', r'(.*)') def f_joy(m, origin, args, text, p=p): p.msg(origin.sender, origin.nick + '!!!') p.bind(f_joy, 'PRIVMSG', r'(?i)(?