def _handle_privmsg(self, message): prefix, command, parameters = Irc.split_message(message) sender, user, ident = Irc.split_prefix(prefix) channel, msg = parameters.split(" ", 1) self.send_event("privmsg", msg[1:], sender, channel) if prefix is None: logger.debug("Malformed PRIVMSG: %s", message) return tokens = parameters.split(' ') # Handles the case of ": <text>". Someone started their message with a space. if tokens[1] == ':': privmsg_command = tokens[2] message = "{} {}".format(privmsg_command, " ".join(tokens[2:])) else: privmsg_command = tokens[1][1:] message = "{} {}".format(privmsg_command, " ".join(tokens[2:])) # CTCP PRIVMSGs if privmsg_command == '\x01PING': self._send_message(Irc.ctcp_pong(sender, message)) if privmsg_command == '\x01ACTION': pass elif privmsg_command[0] == '\x01': logger.debug('Missing CTCP command %s', privmsg_command)
def _handle_part(self, message): prefix, command, parameters = Irc.split_message(message) sender, user, ident = Irc.split_prefix(prefix) if sender == self.config['nick']: channel = parameters.split(" ")[0] self.users.pop(channel) self.send_event("part", channel)
def _handle_notice(self, message): # CTCP PONG if message.split(" ")[3] == ":\x01PING": time_stamp = ".".join(message.split(" ")[-2:])[:-1] time_taken = round(time.time() - float(time_stamp[:-1]), 2) prefix, command, parameters = Irc.split_message(message) user, ident, host = Irc.split_prefix(prefix) self.send_event("pong", str(time_taken), user)
def _handle_join(self, message): prefix, command, parameters = Irc.split_message(message) sender, user, ident = Irc.split_prefix(prefix) if sender == self.config['nick']: channel = parameters[1:] self.channels.append(channel) self.users[channel] = [] self.send_event("join", channel)