Ejemplo n.º 1
0
    def get_all_chats(self):
        """
        Fetches all chats

        :return: List of chats
        :rtype: list[Chat]
        """
        return [
            factory_chat(chat, self)
            for chat in self.wapi_functions.getAllChats()
        ]
Ejemplo n.º 2
0
    def get_unread(self, include_me=False, include_notifications=False):
        # type: (bool, bool) -> list(MessageGroup)
        """
        Fetches unread messages

        :return: List of unread messages grouped by chats
        :rtype: list[MessageGroup]
        """
        raw_message_groups = self.wapi_functions.getUnreadMessages(
            include_me, include_notifications)

        unread_messages = []
        for raw_message_group in raw_message_groups:
            chat = factory_chat(raw_message_group, self)
            messages = [
                factory_message(message, self)
                for message in raw_message_group['messages']
            ]
            unread_messages.append(MessageGroup(chat, messages))

        return unread_messages
Ejemplo n.º 3
0
    def get_unread(self, include_me=False, include_notifications=False):
        """
        Fetches unread messages

        :param include_me: Include user's messages
        :type include_me: bool or None
        :param include_notifications: Include events happening on chat
        :type include_notifications: bool or None
        :return: List of unread messages grouped by chats
        :rtype: list[MessageGroup]
        """
        raw_message_groups = self.wapi_functions.getUnreadMessages(
            include_me, include_notifications)

        unread_messages = []
        for raw_message_group in raw_message_groups:
            chat = factory_chat(raw_message_group, self)
            messages = [
                factory_message(message, self)
                for message in raw_message_group['messages']
            ]
            unread_messages.append(MessageGroup(chat, messages))

        return unread_messages
Ejemplo n.º 4
0
 def contact_get_common_groups(self, contact_id):
     for group in self.wapi_functions.getCommonGroups(contact_id):
         yield factory_chat(group, self)
Ejemplo n.º 5
0
    def get_chat_from_id(self, chat_id):
        for chat in self.wapi_functions.getAllChats():
            if chat["id"] == chat_id:
                return factory_chat(chat, self)

        raise ChatNotFoundError("Chat {0} not found".format(chat_id))