Fix gpxebotrc nick string instead of Who() bug
authorStefan Hajnoczi <stefanha@gmail.com>
Sun, 28 Jun 2009 07:37:22 +0000 (08:37 +0100)
committerStefan Hajnoczi <stefanha@gmail.com>
Sun, 28 Jun 2009 07:37:22 +0000 (08:37 +0100)
cmds.py
gpxebot.py

diff --git a/cmds.py b/cmds.py
index 6d98664..cf83eb6 100644 (file)
--- a/cmds.py
+++ b/cmds.py
@@ -17,6 +17,15 @@ op_commands = {}
 op_members = [config.NICK]
 aliases = {}
 
+class Who(object):
+    def __init__(self, mask, is_identified=False):
+        self.mask = mask
+        self.nick = mask.split('!', 1)[0]
+        self.is_identified = is_identified
+
+    def is_op(self):
+        return self.is_identified and self.nick in op_members
+
 def readrc_command(who=None, target=None, replyto=None, words=None):
     '''Source bot command file (readrc)'''
     try:
@@ -25,7 +34,7 @@ def readrc_command(who=None, target=None, replyto=None, words=None):
         return 'PRIVMSG', (replyto, 'unable to open file')
     cmd = []
     for line in f:
-        response = do_command(config.NICK, config.NICK, config.NICK, line.split())
+        response = do_command(Who(config.NICK, True), config.NICK, config.NICK, line.split())
         if isinstance(response, list):
             cmd += response
         elif response:
index 2e90e33..a20920a 100755 (executable)
@@ -28,15 +28,6 @@ NO_ARGS = -1
 
 handlers = {}
 
-class Who(object):
-    def __init__(self, mask, is_identified=False):
-        self.mask = mask
-        self.nick = mask.split('!', 1)[0]
-        self.is_identified = is_identified
-
-    def is_op(self):
-        return self.is_identified and self.nick in cmds.op_members
-
 def autojoin():
     del handlers['376']
 
@@ -72,7 +63,7 @@ def privmsg(_, target, msg):
     is_identified = msg.startswith('+')
     if msg.startswith('-') or msg.startswith('+'):
         msg = msg[1:]
-    who = Who(mask, is_identified)
+    who = cmds.Who(mask, is_identified)
 
     utils.do_log(cmds.logs, target, who.nick, msg)