def EID_JOIN(self, chat): user_info = { "username": chat["username"], "flags": chat["flags"], "ping": chat["ping"], "ops": False, "squelched": ((chat["flags"] & 0x20) == 0x20), "joined": time.time(), "talked": -1, } user_info.update(statstring(chat["text"])) if chat["username"] == self.bot.status["username"]: user_info["color"] = "user" + out_colors["me"] else: user_info["color"] = self.pick_color() chat["idx"] = self.channel.count self.bot.addchat( user_info["color"], chat["username"], "joinleave", " [" + str(user_info["ping"]) + "ms] has joined the channel using " + user_info["display"], ) self.add_user(chat, user_info)
def EID_SHOWUSER(self, chat): un = chat["username"] if self.channel.has_user(un): update = True else: update = False ops = (chat["flags"] & 0x02) == 0x02 user_info = { "username": un, "flags": chat["flags"], "ping": chat["ping"], "ops": ops, "squelched": ((chat["flags"] & 0x20) == 0x20), "joined": -1, "talked": -1, } user_info.update(statstring(chat["text"])) if chat["username"] == self.bot.status["username"]: user_info["color"] = "user" + out_colors["me"] else: user_info["color"] = self.pick_color() if ops: chat["idx"] = 0 else: chat["idx"] = self.channel.count if update: x = self.channel.user[un.lower()] x.update(user_info) self.update_user(self.channel.order.index(un.lower()), chat, x) else: self.add_user(chat, user_info)
def EID_USERFLAGS(self, chat): if self.channel.has_user(chat["username"]): key = chat["username"].lower() idx = self.channel.order.index(key) ops = bool(chat["flags"] & 0x02) if ops == True and self.channel.user[key]["ops"] == False: self.bot.addchat( self.channel.user[key]["color"], chat["username"], "info", " has gained operator status." ) newidx = 0 del self.channel.order[idx] self.channel.order.insert(newidx, key) else: newidx = -1 self.channel.user[key]["flags"] = chat["flags"] self.channel.user[key]["ops"] = ops self.channel.user[key]["squelched"] = (chat["flags"] & 0x20) == 0x20 self.update_user(idx, chat, self.channel.user[key], newidx) else: un = chat["username"] ops = (chat["flags"] & 0x02) == 0x02 user_info = { "username": un, "flags": chat["flags"], "ping": chat["ping"], "ops": ops, "squelched": ((chat["flags"] & 0x20) == 0x20), "joined": -1, "talked": -1, } if chat["username"] == self.bot.status["username"]: user_info["color"] = "user" + out_colors["me"] else: user_info["color"] = self.pick_color() user_info.update(statstring(chat["text"])) if ops: chat["idx"] = 0 else: chat["idx"] = self.channel.count self.add_user(chat, user_info)