+flirtcfg = (
+ __load("flirts"),
+ ' (but %s is their secret admirer)',
+ "Sorry, but %s made me take Holy Orders.",
+ "Who do you wish me to flirt with?",
+ "My libido is over-used!",
+ fish,
+ 0.1)
+
+# Hacky command to output the current fishpond state
+def fishq(bot, cmd, nick, conn, public,f):
+ from irclib import irc_lower
+ if not public and irc_lower(nick) == irc_lower(bot.owner):
+ state=("Fishpond state: cur_fish=%d, max_fish=%d, nofish_time=%d, "
+ +"fish_time_inc=%d, fish_inc=%d, DoS=%d, Boring_Git=%s, "
+ +"quotatime=%d")%(f.cur_fish,f.max_fish,f.nofish_time,
+ f.fish_time_inc,f.fish_inc,f.DoS,f.Boring_Git,
+ f.quotatime)
+ bot.automsg(public,nick,state)
+
+# Karma implementation
+import cPickle
+karmafilename = "karmadump"
+# load the karma db
+try:
+ f = open(karmafilename, "r")
+ karmadb = cPickle.load(f)
+ f.close()
+except IOError:
+ karmadb = {}
+# Modify karma
+def karma(cmd, amount):
+ thing=cmd.split()[0][:-2].lower()
+ if karmadb.has_key(thing):
+ karmadb[thing] += amount
+ else:
+ karmadb[thing] = amount
+def savekarma():
+ try:
+ f = open(karmafilename, "w")
+ cPickle.dump(karmadb, f)
+ f.close()
+ except IOError:
+ sys.stderr.write("Problems dumping karma: probably lost :(")
+
+# When the bot exits we should save the karma db
+def quit(bot,cmd,nick,conn,public):
+ savekarma()
+ c.quitq(bot,cmd,nick,conn,public)
+def reload(bot,cmd,nick,conn,public):
+ savekarma()
+ c.reloadq(bot,cmd,nick,conn,public)
+
+# Command processing: whenever something is said that the bot can hear,
+# "command" is invoked and must decide what to do. This configuration
+# defines a couple of special cases (for karma) but is otherwise driven
+# by a dictionary of commands.
+
+commands = {"karma": (c.karmaq,karmadb),
+ "karmalist": (c.listkeysq,karmadb),
+ "karmadel": (c.karmadelq,karmadb),
+ "info": (c.infoq,karmadb),
+ "trout": (c.troutq,troutcfg),
+ "flirt": (c.troutq,flirtcfg),
+ "fish": (fishq,fish),
+ "quiet": (c.nofishq,fish),
+ "reload": reload,
+ "quit": quit,
+ "google": c.googleq,
+ "define": c.defineq,
+ "say": c.sayq,
+ "do": c.doq }
+# disconnect and hop annoy people
+# "disconnect": c.disconnq,
+# "hop": c.disconnq }
+commands["list"]=(c.listkeysq,commands)