1 # This file is part of Acrobat.
3 # Acrobat is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published
5 # by the Free Software Foundation; either version 2 of the License,
6 # or (at your option) any later version.
8 # Acrobat is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with Acrobat; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 # Andrew Walkingshaw <andrew@lexical.org.uk>
19 # Peter Corbett <ptc24@cam.ac.uk>
20 # Matthew Vernon <matthew@debian.org>
21 # Stephen Early <steve@greenend.org.uk>
23 # Acrobat configuration file
25 # The following definitions are required to be present in this module:
31 # Also a function called "command"; see later.
33 # Everything else in this file is configuration-specific.
35 # Most command implementations are stored in a separate module.
38 # This fishpond is shared between trouts and flirts. It doesn't have to be;
39 # you can define as many ponds as you like.
50 # load a file full of flirts or trouts
53 f = open(filename, "r")
54 r = [l.strip() for l in f.readlines() if l.find("%s") != -1]
57 r = [ "doesn't know what to do about %s." ]
60 # (troutlist,selftroutmsg,DoSmsg,notargetmsg,nofishmsg,fishpond,selftroutprob)
63 __load("trouts-local"),
64 ' (at the instigation of %s)',
65 "Sorry, but %s is being a spoilsport.",
66 "Who do you wish me to trout?",
67 "Fish stocks exhausted.",
73 ' (but %s is their secret admirer)',
74 "Sorry, but %s made me take Holy Orders.",
75 "Who do you wish me to flirt with?",
76 "My libido is over-used!",
80 # Hacky command to output the current fishpond state
81 def fishq(bot, cmd, nick, conn, public,f):
82 from irclib import irc_lower
83 if not public and irc_lower(nick) == irc_lower(bot.owner):
84 state=("Fishpond state: cur_fish=%d, max_fish=%d, nofish_time=%d, "
85 +"fish_time_inc=%d, fish_inc=%d, DoS=%d, Boring_Git=%s, "
86 +"quotatime=%d")%(f.cur_fish,f.max_fish,f.nofish_time,
87 f.fish_time_inc,f.fish_inc,f.DoS,f.Boring_Git,
89 bot.automsg(public,nick,state)
91 # Karma implementation
93 karmafilename = "karmadump"
96 f = open(karmafilename, "r")
97 karmadb = cPickle.load(f)
102 def karma(cmd, amount):
103 thing=cmd.split()[0][:-2].lower()
104 if karmadb.has_key(thing):
105 karmadb[thing] += amount
107 karmadb[thing] = amount
110 f = open(karmafilename, "w")
111 cPickle.dump(karmadb, f)
114 sys.stderr.write("Problems dumping karma: probably lost :(")
116 # When the bot exits we should save the karma db
117 def quit(bot,cmd,nick,conn,public):
119 c.quitq(bot,cmd,nick,conn,public)
120 def reload(bot,cmd,nick,conn,public):
122 c.reloadq(bot,cmd,nick,conn,public)
124 # Command processing: whenever something is said that the bot can hear,
125 # "command" is invoked and must decide what to do. This configuration
126 # defines a couple of special cases (for karma) but is otherwise driven
127 # by a dictionary of commands.
129 commands = {"karma": (c.karmaq,karmadb),
130 "karmalist": (c.listkeysq,karmadb),
131 "karmadel": (c.karmadelq,karmadb),
132 "info": (c.infoq,karmadb),
133 "trout": (c.troutq,troutcfg),
134 "flirt": (c.troutq,flirtcfg),
135 "fish": (fishq,fish),
136 "quiet": (c.nofishq,fish),
143 # disconnect and hop annoy people
144 # "disconnect": c.disconnq,
145 # "hop": c.disconnq }
146 commands["list"]=(c.listkeysq,commands)
148 triggers = ("!", "~") # what character should the bot be invoked by:
149 # eg !trout, ~trout etc.
151 def command(bot, cmd, nick, conn, public):
154 if public and cmd[0] in triggers:
159 command = cmd.split()[0]
163 if command.endswith("++"):
166 if command.endswith("--"):
169 if ours and command.lower() in commands.keys():
172 e(bot,cmd,nick,conn,public)
174 e[0](bot,cmd,nick,conn,public,*e[1:])