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

[Question] How to add reaction to message from bot? #19

Open
Kariton opened this issue Jan 31, 2023 · 3 comments
Open

[Question] How to add reaction to message from bot? #19

Kariton opened this issue Jan 31, 2023 · 3 comments

Comments

@Kariton
Copy link
Contributor

Kariton commented Jan 31, 2023

It is possible to react to messages from someone else when the bot gets triggerd:

await ctx.react(emoji=command_react)

But cat the bot add a reaction to its own message after sending it (await ctx.send(message))?

@Kariton
Copy link
Contributor Author

Kariton commented Feb 1, 2023

somewhat related: #18 (comment)

@filipre
Copy link
Owner

filipre commented Mar 25, 2023

Yes, using self.bot.react(message: Message, emoji: str) should work for any message. You just need to persist the message object somewhere or build it by yourself again

@filipre
Copy link
Owner

filipre commented Mar 25, 2023

send just returns the timestamp, so to build your own message, you could do something like this

if self._is_phone_number(receiver):
    sent_message = Message(
        source=receiver,  # otherwise we can't respond in the right chat
        timestamp=timestamp,
        type=MessageType.SYNC_MESSAGE,
        text=text,
        base64_attachments=base64_attachments,
        group=None,
    )
else:
    sent_message = Message(
        source=self._phone_number,  # no need to pretend
        timestamp=timestamp,
        type=MessageType.SYNC_MESSAGE,
        text=text,
        base64_attachments=base64_attachments,
        group=receiver,
    )

and then react on it?

Maybe send should always return a Message object like above and not just the timestamp 🤔

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