def disable_bg(self): """Disable background.""" user = User(self._name) user._mbg = False rooms = set(self._rooms.values()) for room in rooms: room.set_bg_mode(0)
def enable_bg(self): """Enable background if available.""" user = User(self._name) user._mbg = True rooms = set(self._rooms.values()) for room in rooms: room.set_bg_mode(1)
def disable_recording(self): """Disable recording.""" user = User(self._name) user._mrec = False rooms = set(self._rooms.values()) for room in rooms: room.set_recording_mode(0)
def enable_recording(self): """Enable recording if available.""" user = User(self._name) user._mrec = True rooms = set(self._rooms.values()) for room in rooms: room.set_recording_mode(1)
def on_receive_unblocked(self, args): if args[2] == "": return target = User(args[2]) user = User(args[3]) self._unban_list.append((args[0], args[1], target, float(args[4]), user)) self.fire_event("unban", user, target) self.request_unban_list()
def set_font_color(self, color3x): """ Set font color. @type color3x: str @param color3x: a 3-char RGB hex code for the color """ user = User(self._name) user._font_color = color3x
def set_font_face(self, face): """ Set font face/family. @type face: str @param face: the font face """ user = User(self._name) user._font_face = face
def set_font_size(self, size): """ Set font size. @type size: int @param size: the font size (limited: 9 to 22) """ if size < 9: size = 9 if size > 22: size = 22 user = User(self._name) user._font_size = size
def on_receive_wl(self, args): self._contacts = set() for i in range(len(args) // 4): name, last_on, is_on, idle = args[i * 4:i * 4 + 4] user = User(name) self._contacts.add(user) self.fire_event("pm_contact_list_receive")
def on_receive_g_participants(self, args): args = ":".join(args) args = args.split(";") self._user_count = len(args) for data in args: data = data.split(":") name = data[3] uid = name.lower() if uid == "none": continue self._recent_list.append(uid) user = User( uid=name, room=self ) user.add_session_id(self, data[0]) self._user_list.append(user)
def on_receive_msg(self, args): user = User(args[0]) # Clean message body = strip_html(":".join(args[5:]))\ .replace("<", "<")\ .replace(">", ">")\ .replace(""", "\"")\ .replace("'", "'")\ .replace("&", "&") self.fire_event("pm_message", user, body)
def on_receive_unblocklist(self, args): self._unban_list = list() sections = ":".join(args).split(";") for section in sections: params = section.split(":") if len(params) != 5: continue if params[2] == "": continue self._unban_list.append(( # unid params[0], # ip params[1], # target User(params[2]), # time float(params[3]), # src User(params[4]) )) self.fire_event("unban_list_update")
def on_receive_i(self, args): mtime = float(args[0]) puid = args[3] ip = args[6] if ip == "": ip = None name = args[1] rawmsg = ":".join(args[9:]) msg, n, f = clean_message(rawmsg) msgid = args[5] unid = args[4] if name == "": name_color = None name = "#" + args[2] if name == "#": name = "!anon" + get_anon_id(n, puid) else: if n: name_color = parse_name_color(n) else: name_color = None if f: font_color, font_face, font_size = parse_font(f) else: font_color, font_face, font_size = None, None, None msg = self.create_message( msgid=msgid, time=mtime, user=User(name), body=msg, raw=rawmsg, ip=ip, unid=unid, name_color=name_color, font_color=font_color, font_face=font_face, font_size=font_size, room=self ) if msg.user != self._manager.user: msg.user._font_color = msg.font_color msg.user._font_face = msg.font_face msg.user._font_size = msg.font_size msg.user._name_color = msg.name_color self._i_log.append(msg)
def on_receive_participant(self, args): if args[0] == "0": #leave name = args[3] uid = name.lower() if uid == "none": return if uid in self._recent_list: self._recent_list.remove(uid) user = User(name) user.remove_session_id(self, args[1]) self._user_list.remove(user) if ( user not in self._user_list or not self._user_list_event_unique ): self.fire_event("leave", user) else: #join name = args[3] uid = name.lower() if uid == "none": return if not uid in self._recent_list: self._recent_list.append(uid) user = User( uid=name, room=self ) user.add_session_id(self, args[1]) if user not in self._user_list: do_event = True else: do_event = False self._user_list.append(user) if do_event or not self._user_list_event_unique: self.fire_event("join", user)
def on_receive_b(self, args): mtime = float(args[0]) puid = args[3] ip = args[6] name = args[1] rawmsg = ":".join(args[9:]) msg, n, f = clean_message(rawmsg) if name == "": name_color = None name = "#" + args[2] if name == "#": name = "!anon" + get_anon_id(n, puid) else: if n: name_color = parse_name_color(n) else: name_color = None i = args[5] unid = args[4] #Create an anonymous message and queue it because msgid is unknown. if f: font_color, font_face, font_size = parse_font(f) else: font_color, font_face, font_size = None, None, None msg = RoomMessage( time=mtime, user=User(name), body=msg, raw=rawmsg, uid=puid, ip=ip, name_color=name_color, font_color=font_color, font_face=font_face, font_size=font_size, unid=unid, room=self ) self._message_queue[i] = msg
def on_receive_connect(self, args): self.fire_event("pm_connect1", User(args[0]), args[1], args[2])
def on_receive_wloffline(self, args): self.fire_event("pm_contact_offline", User(args[0]))
def on_receive_msgoff(self, args): user = User(args[0]) body = strip_html(":".join(args[5:])) self.fire_event("pm_offline_message", user, body)
def on_receive_unblock_list(self, args): self._unblock_list = set() for name in args: if name == "": continue self._unblock_list.add(User(name))
def get_user(self): return User(self._name)