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>
22 # Richard Kettlewell <rjk@greenend.org.uk
24 # Acrobat configuration file
26 # The following definitions are required to be present in this module:
27 server = "irc.nsict.org"
30 channel = "#artichoke"
32 # Also a function called "command"; see later.
34 # Everything else in this file is configuration-specific.
38 # Most command implementations are stored in a separate module.
41 # This fishpond is shared between trouts and flirts. It doesn't have to be;
42 # you can define as many ponds as you like.
53 # load a file full of flirts or trouts
56 f = open(filename, "r")
57 r = [l.strip() for l in f.readlines() if l.find("%s") != -1]
60 r = [ "doesn't know what to do about %s." ]
63 # (troutlist,selftroutmsg,DoSmsg,notargetmsg,nofishmsg,fishpond,selftroutprob)
66 ' (at the instigation of %s)',
67 "Sorry, but %s is being a spoilsport.",
68 "Who do you wish me to trout?",
69 "Fish stocks exhausted.",
75 ' (but %s is their secret admirer)',
76 "Sorry, but %s made me take Holy Orders.",
77 "Who do you wish me to flirt with?",
78 "My libido is over-used!",
84 ' (while %s watches)',
85 "Sorry, but %s stole my pen.",
86 "Who do you want to slash?",
87 "I have writer's block!",
91 # Hacky command to output the current fishpond state
92 def fishq(bot, cmd, nick, conn, public,f):
93 from irclib import irc_lower
94 if not public and irc_lower(nick) == irc_lower(bot.owner):
95 state=("Fishpond state: cur_fish=%d, max_fish=%d, nofish_time=%d, "
96 +"fish_time_inc=%d, fish_inc=%d, DoS=%d, Boring_Git=%s, "
97 +"quotatime=%d")%(f.cur_fish,f.max_fish,f.nofish_time,
98 f.fish_time_inc,f.fish_inc,f.DoS,f.Boring_Git,
100 bot.automsg(public,nick,state)
102 # Karma implementation
104 karmafilename = "artichoke-karma"
107 f = open(karmafilename, "r")
108 karmadb = cPickle.load(f)
113 def karma(cmd, amount):
114 thing=cmd.split()[0][:-2].lower()
115 if karmadb.has_key(thing):
116 karmadb[thing] += amount
118 karmadb[thing] = amount
121 tmp = "%s.tmp" % karmafilename
124 cPickle.dump(karmadb, f)
126 os.rename(tmp, karmafilename)
128 sys.stderr.write("error writing karma: %s" % e)
130 def quit(bot,cmd,nick,conn,public):
131 c.quitq(bot,cmd,nick,conn,public)
132 def reload(bot,cmd,nick,conn,public):
133 c.reloadq(bot,cmd,nick,conn,public)
139 minlose=24*60*60 #1 day
140 maxlose=14*minlose #2 weeks
141 losetime=time.time()+300000
143 # Command processing: whenever something is said that the bot can hear,
144 # "command" is invoked and must decide what to do. This configuration
145 # defines a couple of special cases (for karma) but is otherwise driven
146 # by a dictionary of commands.
148 commands = {"karma": (c.karmaq,karmadb),
149 "karmalist": (c.listkeysq,karmadb),
150 "karmadel": (c.karmadelq,karmadb),
151 "info": (c.infoq,karmadb),
152 "trout": (c.troutq,troutcfg),
153 "slash": (c.slashq, slashcfg),
155 "fish": (fishq,fish),
156 "flirt": (c.troutq,flirtcfg),
157 "quiet": (c.nofishq,fish),
162 # "define": c.defineq,
163 # "game": (c.gameq,game),
166 # disconnect and hop annoy people
167 # "disconnect": c.disconnq,
168 # "hop": c.disconnq }
169 commands["list"]=(c.listkeysq,commands)
171 triggers = ("!", "~") # what character should the bot be invoked by:
172 # eg !trout, ~trout etc.
174 def command(bot, cmd, nick, conn, public):
177 if public and cmd[0] in triggers:
182 command = cmd.split()[0]
186 if command.endswith("++"):
189 if command.endswith("--"):
192 if ours and command.lower() in commands.keys():
193 e=commands[command.lower()]
195 e(bot,cmd,nick,conn,public)
197 e[0](bot,cmd,nick,conn,public,*e[1:])
199 # if cmd.find("GAME")!=-1: #someone else lost
200 # grace.grace=time.time()+60*20
201 # elif cmd.find(game.trigger)!=-1 and len(game.trigger)>2: #we lost!
202 # c.gameq(bot,"pad "+game.trigger,bot.owner,conn,False,game)
203 # elif time.time()>game.losetime: #we randomly lost, take new trigger
204 # c.gameq(bot,cmd,bot.owner,conn,False,game)