Fix gpxebotrc nick string instead of Who() bug
[people/stefanha/gpxebot.git] / cmds.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: