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

Add reactions support. #142

Merged
merged 3 commits into from
Feb 16, 2024
Merged

Conversation

ti-bone
Copy link
Contributor

@ti-bone ti-bone commented Feb 15, 2024

What

This introduces support for handling new reactions that are set on messages.
Adds new filters:
Reaction.FromUserID(id int64) - Checks whether the reaction from specified user or not.
Reaction.FromAnonymousChatID(id int64) - Checks whether the reaction from specified anonymous channel\admin or not.
Reaction.FromChatID(id int64) - Checks if the reaction has been set in specified chat
Reaction.New(Old)ReactionIn(reaction string) - Checks if the newly set(removed) reaction contains emoji, which is provided as reaction argument.

Impact

  • Are your changes backwards compatible? Y
  • Have you included documentation, or updated existing documentation? Not required.
  • Do errors and log messages provide enough context? Not required.

Copy link
Owner

@PaulSonOfLars PaulSonOfLars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Some small changes but otherwise very happy with this.
Thanks a lot!

ext/handlers/filters/reaction/reaction.go Outdated Show resolved Hide resolved
ext/handlers/filters/reaction/reaction.go Outdated Show resolved Hide resolved
Comment on lines 12 to 22
func FromUserID(id int64) filters.Reaction {
return func(mru *gotgbot.MessageReactionUpdated) bool {
if mru.User != nil {
return mru.User.Id == id
}

return false
}
}

func FromAnonymousChatID(id int64) filters.Reaction {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Random thought: should we be merging this to a single item? How are the other handlers doing it? I'm not sure it makes sense to have both, since only one can trigger.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, yep, correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you think about merge them and name as FromPeer?
I don't know how Telegram names such things exactly in BotAPI, but in MTProto it's named usually as Peer.

…rename FromChatID to ChatID, rename New(Old)ReactionIn to New(Old)ReactionEmoji.
@ti-bone
Copy link
Contributor Author

ti-bone commented Feb 15, 2024

Reaction.FromPeer(id int64) - Was renamed and merged from FromUserID and FromAnonymousChatID, checks if the specified peer(user or anonymous channel) sent this reaction update.

@PaulSonOfLars PaulSonOfLars enabled auto-merge (squash) February 16, 2024 17:04
@PaulSonOfLars PaulSonOfLars enabled auto-merge (squash) February 16, 2024 17:05
@PaulSonOfLars PaulSonOfLars merged commit c18b68e into PaulSonOfLars:v2 Feb 16, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

2 participants