/[shmookey]/killbot/easybot.py


UCC Code Repository

Diff of /killbot/easybot.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 121 by shmookey, Sun Sep 13 03:06:49 2009 UTC revision 122 by shmookey, Wed Sep 16 01:39:09 2009 UTC
# Line 8  from ircbot import SingleServerIRCBot Line 8  from ircbot import SingleServerIRCBot
8  from irclib import nm_to_n  from irclib import nm_to_n
9    
10  class EasyBot(SingleServerIRCBot):  class EasyBot(SingleServerIRCBot):
11          def __init__(self, channel, nickname, server, port=6667):          def __init__(self, nickname, server, port=6667):
12                  SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname)                  SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname)
13                  self.channel = channel                  self.welcome_hook = False
14                    self.message_hook = False
15    
16          def on_nicknameinuse(self, c, e):          def on_nicknameinuse(self, c, e):
17                  c.nick(c.get_nickname() + "_")                  c.nick(c.get_nickname() + "_")
18    
19          def on_welcome(self, c, e):          def on_welcome(self, c, e):
20                  c.join(self.channel)                  if self.welcome_hook: self.welcome_hook (c)
21    
22          def on_privmsg(self, c, e):          def on_privmsg(self, c, e):
23                  self.do_command(e, e.arguments()[0])                  pass
24    
25          def on_pubmsg(self, c, e):          def on_pubmsg(self, c, e):
26                  self.do_command(e, e.arguments()[0])                  self.do_command(e, e.arguments()[0])
# Line 27  class EasyBot(SingleServerIRCBot): Line 28  class EasyBot(SingleServerIRCBot):
28          def do_command(self, e, cmd):          def do_command(self, e, cmd):
29                  nick = nm_to_n(e.source())                  nick = nm_to_n(e.source())
30                  c = self.connection                  c = self.connection
31                    channel = e.target ()
32    
33                  chobj = self.channels [self.channel]                  chobj = self.channels [channel]
34                  opers = chobj.opers()                  opers = chobj.opers()
35                  if self.message_hook: self.message_hook (chobj = c, channel = self.channel, msg_from = nick, msg = e.arguments()[0], is_oper = (nick in opers))                  if self.message_hook: self.message_hook (chobj = c, channel = channel, msg_from = nick, msg = e.arguments()[0], is_oper = (nick in opers))
36    

Legend:
Removed from v.121  
changed lines
  Added in v.122

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26