def _async_process(self):
        while not self._stop_event.is_set():
            time.sleep(0.01)
            try:
                args = self._in_queue.get_nowait()
                #These "msg"s will be raw irc received lines, which have several forms
                # basically, we should be looking for
                # :User!Name@host COMMAND <ARGS>
                logging.debug(args)
                userhost = user_re.search(args[0][1:])

                if userhost:

                    nick, host, user = userhost.groups()

                    command = args[1]

                    if command == 'JOIN':
                        channel = args[2][1:] #JOIN Channels are : prefixed
                        for handler in self._handlers['join']:
                            handler(self, nick, host, channel)
                    elif command == 'TOPIC':
                        channel = args[2]
                        topic = ' '.join(args[3:])
                        for handler in self._handlers['topic']:
                            handler(self, nick, host, channel, topic)
                    elif command == 'PART':
                        channel = args[2]
                        message = ' '.join(args[3:])
                        for handler in self._handlers['part']:
                            handler(self, nick, host, channel, message)
                    elif command == 'PRIVMSG':
                        channel = args[2]
                        message = ' '.join(args[3:])[1:]
                        for handler in self._handlers['msg']:
                            handler(self, nick, host, channel, message)
                        if channel[0] == '#':
                            #this is a channel
                            for handler in self._handlers['chanmsg']:
                                handler(self, nick, host, channel, message)
                        else:
                            #private message
                            for handler in self._handlers['privmsg']:
                                handler(self, nick, host, message)
                    elif command == 'KICK':
                        channel = args[2]
                        kicked_nick = args[3]
                        reason = ' '.join(args[4:])[1:]
                        for handler in self._handlers['kick']:
                            handler(self, nick, host, channel, kicked_nick, reason)
                    elif command == 'NICK':
                        new_nick = args[2][1:]
                        for handler in self._handlers['nick']:
                            handler(self, nick, new_nick, host)
                    elif command == 'NOTICE':
                        #:nick!user@host NOTICE <userchan> :message
                        channel = args[2]
                        message = ' '.join(args[3:])
                        for handler in self._handlers['notice']:
                            handler(self, nick, host, channel, message)
                    else:
                        logging.warning(command % "Unhandled command %s")

                self._in_queue.task_done()
            except queue.Empty as e: pass
            except Exception as e:
                logging.debug(e.args)
dataset/ETHPy150Open kageurufu/AsyncIRC/asyncirc/ircbot.py/IRCBot._async_process/swapped operands of `%`