def onCtcp(self, chan, who, cmd, arg): if cmd == "VERSION": self.notice(who.nick, "\x01VERSION Schongo Bot %s\x01" % version) elif cmd == "PING": self.notice(who.nick, "\x01PING %s\x01" % arg) else: modules.fire_hook("ctcp", modules.IrcContext(self, chan, who), cmd, arg)
def onMessage(self, msg): # Call the parent so we still function. IrcClient.onMessage(self, msg) # Fire off an event for modules to eat modules.fire_hook("irc_%s" % msg.command, modules.IrcContext(self, None, msg.origin), msg)
def onNotice(self, target, who, message): if not self._ns_authed and who.nick == self._ns_name: if self._ns_find in message: self.say(self._ns_name, "IDENTIFY %s" % self._ns_pass) else: # Intentionally don't allow it to intercept NickServ messages. modules.fire_hook("notice", modules.IrcContext(self, target, who), message)
def onConnected(self): IrcClient.onConnected(self) if self.user_modes is not None: self.sendMessage("MODE", self.nick, self.user_modes) modules.fire_hook("connected", self) for i in self.channels: self.join_channel(i)
def onDisconnected(self): modules.fire_hook("disconnected", self) IrcClient.onDisconnected(self) global connections connections -= 1 if connections == 0: self.logger.info("Shutting down.") modules.shutdown()
def lineReceived(self, line): prefix = "" line_split = line.split(" ") if line_split[0].startswith(":"): line_split[0] = line_split[0][1:] prefix = line_split[0] line_split = line_split[1:] command = line_split[0] params = line_split[1:] parsed_params = [] index = 0 for param in params: if param.startswith(':'): param = param[1:] params[index] = param parsed_params.append(' '.join(params[index:])) break else: parsed_params.append(param) index += 1 logging.debug("Recieved command {0}".format(command)) modules.fire_hook(command, self, prefix, parsed_params)
def onNick(self, old, new): modules.fire_hook("nick", modules.IrcContext(self, None, old), new)
def onTopic(self, who, chan, topic): modules.fire_hook("topic", modules.IrcContext(self,chan,who),topic)
def onQuit(self, who, message): modules.fire_hook("quit", modules.IrcContext(self, None, who))
def onPart(self, who, chan, msg): modules.fire_hook("part", modules.IrcContext(self, chan, who))
def onJoin(self, who, chan): modules.fire_hook("join", modules.IrcContext(self, chan, who))
def onAction(self, chan, who, what): modules.fire_hook("action", modules.IrcContext(self, chan, who), what)
def onMsg(self, chan, who, what): modules.fire_hook("message", modules.IrcContext(self, chan, who), what)
def onMode(self, who, chan, mode, args): modules.fire_hook("mode", modules.IrcContext(self, chan, who), mode, args)
def onNotice(self, target, who, message): if not self._ns_authed and who.nick == self._ns_name: if self._ns_find in message: self.say(self._ns_name, "IDENTIFY %s" % self._ns_pass) else: # Intentionally don't allow it to intercept NickServ messages. modules.fire_hook("notice", modules.IrcContext(self, target, who), message);
def onTopic(self, who, chan, topic): modules.fire_hook("topic", modules.IrcContext(self, chan, who), topic)
def onConnected(self): IrcClient.onConnected(self) modules.fire_hook("connected", self) for i in self.channels: self.join_channel(i)