- cmd = pieces[0].upper()
- if cmd == "EVAL":
- try: ret = eval(' '.join(pieces[1:]))
- except: self.msg(chan, "Error: %s %s" % (sys.exc_info()[0], sys.exc_info()[1]))
- else: self.msg(chan, "Done: %r" % (ret))
- elif cmd == "EXEC":
- try: exec ' '.join(pieces[1:])
- except: self.msg(chan, "Error: %s %s" % (sys.exc_info()[0], sys.exc_info()[1]))
- else: self.msg(chan, "Done.")
- #TODO
+
+ if target == self.nick:
+ if len(pieces) > 1:
+ chanword = pieces[1]
+ if chanword[0] == '#':
+ chan = self.parent.channel(chanword)
+ pieces.pop(1)
+
+ else: # message was sent to a channel
+ chan = self.parent.channel(target) #TODO check if bot's on channel --- in Erebus.channel() maybe?
+ if msg[0] == '*': # message may be addressed to bot by "*BOTNICK" trigger?
+ if pieces[0][1:].lower() == self.nick.lower():
+ pieces.pop(0) # command actually starts with next word
+ msg = ' '.join(pieces) # command actually starts with next word
+ elif not triggerused:
+ return # not to bot, don't process!
+
+ cmd = pieces[0].lower()
+
+ if self.parent.hashook(cmd):
+ callback = self.parent.gethook(cmd)
+ if chan is None and callback.needchan:
+ self.msg(user, "You need to specify a channel for that command.")
+ return
+ if user.glevel >= callback.reqglevel:
+ #TODO TODO TODO check reqclevel
+ cbret = callback(self, user, chan, target, *pieces[1:])
+ if cbret is NotImplemented:
+ self.msg(user, "Command not implemented.")
+ return
+
+ self.msg(user, "No such command, or you don't have access.")