def __handle_privmsg(self, source, target, message): nick = get_irc_nick(source) if target == self.nick: if message[0] == '\x01': endindex = message[1:].find('\x01') if endindex == -1: return ctcp = message[1:endindex + 1] if ctcp.upper() == 'VERSION': self.send_raw('PRIVMSG ' + nick + ' :\x01VERSION xchat 2.8.8 Ubuntu\x01') return if nick not in self.built_privmsg: if message[0] != COMMAND_PREFIX: debug('message not a cmd') return #new message starting cmd_string = message[1:].split(' ')[0] if cmd_string not in plaintext_commands + encrypted_commands: debug('cmd not in cmd_list, line="' + message + '"') return self.built_privmsg[nick] = [cmd_string, message[:-2]] else: self.built_privmsg[nick][1] += message[:-2] box, encrypt = self.__get_encryption_box(self.built_privmsg[nick][0], nick) if message[-1]==';': self.waiting[nick]=True elif message[-1]=='~': self.waiting[nick]=False if encrypt: if not box: debug('error, dont have encryption box object for ' + nick + ', dropping message') return #need to decrypt everything after the command string to_decrypt = ''.join(self.built_privmsg[nick][1].split(' ')[1]) try: decrypted = enc_wrapper.decode_decrypt(to_decrypt, box) except ValueError as e: debug('valueerror when decrypting, skipping: ' + repr(e)) return parsed = self.built_privmsg[nick][1].split(' ')[0] + ' ' + decrypted else: parsed = self.built_privmsg[nick][1] #wipe the message buffer waiting for the next one del self.built_privmsg[nick] debug("<<privmsg nick=%s message=%s" % (nick, parsed)) self.__on_privmsg(nick, parsed) else: #drop the bad nick del self.built_privmsg[nick] elif target == self.channel: debug("<<pubmsg nick=%s message=%s" % (nick, message)) self.__on_pubmsg(nick, message) else: debug('what is this? privmsg src=%s target=%s message=%s;' % (source, target, message))
def __handle_privmsg(self, source, target, message): nick = get_irc_nick(source) if target == self.nick: if message[0] == "\x01": endindex = message[1:].find("\x01") if endindex == -1: return ctcp = message[1 : endindex + 1] if ctcp.upper() == "VERSION": self.send_raw("PRIVMSG " + nick + " :\x01VERSION xchat 2.8.8 Ubuntu\x01") return if nick not in self.built_privmsg: if message[0] != COMMAND_PREFIX: debug("message not a cmd") return # new message starting cmd_string = message[1:].split(" ")[0] if cmd_string not in plaintext_commands + encrypted_commands: debug('cmd not in cmd_list, line="' + message + '"') return self.built_privmsg[nick] = [cmd_string, message[:-2]] else: self.built_privmsg[nick][1] += message[:-2] box = self.__get_encryption_box(self.built_privmsg[nick][0], nick) if message[-1] == ";": self.waiting[nick] = True elif message[-1] == "~": self.waiting[nick] = False if box: # need to decrypt everything after the command string to_decrypt = "".join(self.built_privmsg[nick][1].split(" ")[1]) decrypted = enc_wrapper.decode_decrypt(to_decrypt, box) parsed = self.built_privmsg[nick][1].split(" ")[0] + " " + decrypted else: parsed = self.built_privmsg[nick][1] # wipe the message buffer waiting for the next one del self.built_privmsg[nick] debug("<<privmsg nick=%s message=%s" % (nick, parsed)) self.__on_privmsg(nick, parsed) else: # drop the bad nick del self.built_privmsg[nick] elif target == self.channel: debug("<<pubmsg nick=%s message=%s" % (nick, message)) self.__on_pubmsg(nick, message) else: debug("what is this? privmsg src=%s target=%s message=%s;" % (source, target, message))