4 # Andrew Walkingshaw <andrew@lexical.org.uk>
7 # Joel Rosdahl <joel@rosdahl.net>
10 # Peter Corbett <ptc24@cam.ac.uk>
11 # Matthew Vernon <matthew@debian.org>
13 # Stephen Early <steve@greenend.org.uk> mostly deleted stuff
15 # This file is part of Acrobat.
17 # Acrobat is free software; you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published
19 # by the Free Software Foundation; either version 2 of the License,
20 # or (at your option) any later version.
22 # Acrobat is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
27 # You should have received a copy of the GNU General Public License
28 # along with Acrobat; if not, write to the Free Software
29 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
33 Acrobat - an extensible, minmalist irc bot.
37 from ircbot import SingleServerIRCBot
38 from irclib import nm_to_n, irc_lower
40 class Acrobat(SingleServerIRCBot):
41 def __init__(self,config):
44 nickname=config.nickname
45 SingleServerIRCBot.__init__(self,
46 [(server, port)], nickname, nickname)
47 self.channel = config.channel
48 self.owner = config.owner
49 self.revision = "$Revision: 1.1 $" # global version number
54 def on_welcome(self, conn, evt):
55 conn.join(self.channel)
57 def on_privmsg(self, conn, evt):
58 self.do_command(nm_to_n(evt.source()), evt.arguments()[0])
60 def on_pubmsg(self, conn, evt):
61 payload = evt.arguments()[0]
62 nc = string.split(payload, " ", 1)
63 if len(nc) > 1 and (irc_lower(nc[0]).startswith(
64 irc_lower(self.connection.get_nickname()))):
65 self.do_command(nm_to_n(evt.source()), nc[1].strip(), public = 1)
67 self.do_command(nm_to_n(evt.source()), payload.strip(), public = 1)
68 # General query handler
69 def do_command(self, nick, cmd, public=0):
70 self.config.command(self,cmd,nick,self.connection,public)
72 # Convenience function - reply to a public message publicly, or
73 # a private message privately
74 def automsg(self,public,nick,msg):
76 self.connection.privmsg(self.channel,msg)
78 self.connection.notice(nick, msg)
82 print "acrobat: provide configuration module name on command line"
85 c=__import__(sys.argv[1])
87 print "acrobat: configuration module "+sys.argv[1]+".py not found"
92 if __name__ == "__main__":