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
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