krypton-byte / neonize

whatsapp automation library, written in python
http://krypton-byte.me/neonize/
Apache License 2.0
70 stars 17 forks source link

How do you get messages from group? #44

Open lfaltoni opened 1 month ago

lfaltoni commented 1 month ago

Hi, i cannot figure out how to get messages from group.

I have checked the docs and all I can find is the get_newsletter_messages() function, but I cannot understand how to find the “before” argument, and what the function expects.

Docs says the before argument is optional, but I get the following

error: An unexpected error occurred while retrieving messages: argument 5: TypeError: 'NoneType' object cannot be interpreted as an integer

Could you tell me if I’m correctly using this function? If not, what’s the best function to get messages from WhatsApp groups?

def get_newsletter_message_update(
        self, jid: JID, count: int, since: int, after: int
    ) -> RepeatedCompositeFieldContainer[NewsletterMessage]:
        """Retrieves a list of newsletter messages that have been updated since a given timestamp.

        :param jid: The JID (Jabber ID) of the user.
        :type jid: JID
        :param count: The maximum number of messages to retrieve.
        :type count: int
        :param since: The timestamp (in milliseconds) to retrieve messages from.
        :type since: int
        :param after: The timestamp (in milliseconds) to retrieve messages after.
        :type after: int

        :return: A list of updated newsletter messages.
        :rtype: RepeatedCompositeFieldContainer[NewsletterMessage]

        :raises GetNewsletterMessageUpdateError: If there was an error retrieving the newsletter messages.
        """
        jidbyte = jid.SerializeToString()
        model = neonize_proto.GetNewsletterMessageUpdateReturnFunction.FromString(
            self.__client.GetNewsletterMessageUpdate(
                self.uuid, jidbyte, len(jidbyte), count, since, after
            ).get_bytes()
        )
        if model.Error:
            raise GetNewsletterMessageUpdateError(model.Error)
        return model.NewsletterMessage

get_newsletter_messages(jid, count, before) Retrieves a list of newsletter messages for a given JID.

Parameters: jid (JID) – The JID (Jabber Identifier) of the user.

count (int) – The maximum number of messages to retrieve.

before (MessageServerID) – The ID of the message before which to retrieve messages.

Returns: A list of newsletter messages.

Return type: RepeatedCompositeFieldContaine[NewsletterMessage]

Hendroarifin commented 1 month ago

To retrieve messages from the group, I am using this to get information about incoming messages, whether they are from the group or not.

message.Info.MessageSource.IsGroup

lfaltoni commented 1 month ago

To retrieve messages from the group, I am using this to get information about incoming messages, whether they are from the group or not.

message.Info.MessageSource.IsGroup

Sorry, could you explain better? Where do you use that?