예제 #1
0
    def get_chat_from_id(self, chat_id):
        chats = filter(lambda chat: chat["id"] == chat_id,
                       self.wapi_functions.getAllChats())

        assert len(chats) == 1, "Chat {0} not found".format(chat_id)

        return Chat(chats[0], self)
예제 #2
0
    def get_all_chats(self):
        # type: (Chat ,bool, bool) -> list(Message)
        """
        Fetches all chats

        :return: List of chats
        :rtype: list[Chat]
        """
        return [Chat(chat, self) for chat in self.wapi_functions.getAllChats()]
예제 #3
0
    def get_unread(self):
        """
        Fetches unread messages

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

        unread_messages = []
        for raw_message_group in raw_message_groups:
            chat = Chat(raw_message_group)
            pp.pprint(raw_message_group)
            messages = [
                Message(message) for message in raw_message_group["messages"]
            ]
            unread_messages.append(MessageGroup(chat, messages))

        return unread_messages
예제 #4
0
    def get_unread(self, include_me=False, include_notifications=False):
        """
        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 = Chat(raw_message_group)
            messages = [
                Message(message) for message in raw_message_group["messages"]
            ]
            unread_messages.append(MessageGroup(chat, messages))

        for message in unread_messages:
            message.chat.driver = self

        return unread_messages
예제 #5
0
 def get_all_chats(self):
     return [Chat(chat, self) for chat in self.wapi_functions.getAllChats()]