+ if target == self.nick:
+ if msg[0] == "\001": #ctcp
+ msg = msg.strip("\001")
+ if msg == "VERSION":
+ self.msg(user, "\001VERSION Erebus v%d.%d - http://github.com/zonidjan/erebus" % (self.parent.APIVERSION, self.parent.RELEASE))
+ return
+ if len(pieces) > 1:
+ chanword = pieces[1]
+ if chanword[0] == '#':
+ chan = self.parent.channel(chanword)
+ if chan is not None: #if chan is still none, there's no bot on "chanword", and chanword is used as a parameter.
+ pieces.pop(1)
+
+ else: # message was sent to a channel
+ chan = self.parent.channel(target)
+ try:
+ 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:
+ if self.parent.haschanhook(target.lower()):
+ for callback in self.parent.getchanhook(target.lower()):
+ cbret = callback(self, user, chan, *pieces)
+ if cbret is NotImplemented:
+ self.msg(user, "Command not implemented.")
+ return # not to bot, don't process!
+ except IndexError:
+ return # "message" is empty
+
+ cmd = pieces[0].lower()
+
+ if self.parent.hashook(cmd):
+ for callback in self.parent.gethook(cmd):
+ if chan is None and callback.needchan:
+ self.msg(user, "You need to specify a channel for that command.")
+ elif user.glevel >= callback.reqglevel and (not callback.needchan or chan.levelof(user.auth) >= callback.reqclevel):
+ cbret = callback(self, user, chan, target, *pieces[1:])
+ if cbret is NotImplemented:
+ self.msg(user, "Command not implemented.")