Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you get messages from group? #44

Open
lfaltoni opened this issue Oct 6, 2024 · 2 comments
Open

How do you get messages from group? #44

lfaltoni opened this issue Oct 6, 2024 · 2 comments

Comments

@lfaltoni
Copy link

lfaltoni commented Oct 6, 2024

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

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
Copy link
Author

lfaltoni commented Oct 7, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants