Esempio n. 1
0
    def add_buddy(self, char_id, _type):
        if not char_id:
            return False

        # check if we are trying to add a conn as a buddy
        if self.is_conn_char_id(char_id):
            return False

        buddy = self.get_buddy(char_id)
        if buddy:
            buddy["types"].append(_type)
        else:
            conn = self.get_conn_for_new_buddy()
            if not conn:
                self.logger.warning(
                    f"Could not add buddy '{char_id}' with type '{_type}' since buddy list is full"
                )
            else:
                if conn.char_id != char_id:
                    conn.send_packet(client_packets.BuddyAdd(char_id, "\1"))
                    self.buddy_list[conn.id][char_id] = {
                        "online": None,
                        "types": [_type],
                        "conn_id": conn.id
                    }

        return True
Esempio n. 2
0
    def add_buddy(self, char_id, _type):
        if char_id and char_id != self.bot.char_id:
            if char_id not in self.buddy_list:
                self.bot.send_packet(client_packets.BuddyAdd(char_id, "\1"))
                self.buddy_list[char_id] = {"online": None, "types": [_type]}
            elif _type not in self.buddy_list[char_id]["types"]:
                self.buddy_list[char_id]["types"].append(_type)

            return True
        else:
            return False
Esempio n. 3
0
    def add_buddy(self, char, _type):
        char_id = self.character_manager.resolve_char_to_id(char)
        if char_id and char_id != self.bot.char_id:
            if char_id not in self.buddy_list:
                self.bot.send_packet(client_packets.BuddyAdd(char_id, "\1"))
                self.buddy_list[char_id] = {"online": None, "types": [_type]}
            else:
                self.buddy_list[char_id]["types"].append(_type)

            return True
        else:
            return False
Esempio n. 4
0
    def add_buddy(self, char_id, _type):
        if not char_id:
            return False

        # check if we are trying to add a conn as a buddy
        if self.is_conn_char_id(char_id):
            return False

        buddy = self.get_buddy(char_id)
        if buddy:
            buddy["types"].append(_type)
        else:
            conn = self.get_conn_for_new_buddy()
            conn.send_packet(client_packets.BuddyAdd(char_id, "\1"))
            conn.buddy_list[char_id] = {
                "online": None,
                "types": [_type],
                "conn_id": conn.id
            }

        return True