Skip to content

[FEATURE] Make tg.Bot comparable #2319

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

Closed
Bibo-Joshi opened this issue Jan 15, 2021 · 0 comments · Fixed by #2320
Closed

[FEATURE] Make tg.Bot comparable #2319

Bibo-Joshi opened this issue Jan 15, 2021 · 0 comments · Fixed by #2320
Labels
ℹ️ good-first-issue information: good-first-issue

Comments

@Bibo-Joshi
Copy link
Member

tg.Bot didn't get rich comparison in #1724, though there are use cases when comparison of Bot with User objects would be helpful. Most notable when checking if the bot is one of the new chat members reportet in a status update; with rich comparison that would be as easy as

context.bot in update.effective_message.new_chat_members

Currently one can use bot_instance.bot, which holds the User instance for comparison, but it's undocumented and unintuitive. Proposal:

  • Make Bot.__eq__(self, other) basically return self.bot == other and document the behaviour accordingly
  • we need to make sure that self.bot is already set. For the Bot.{id, username, …} properties, that's currently done with the @info decorator. I think it would be cleaner to just convert self.bot into a property that calls self.get_me() if needed.
@Bibo-Joshi Bibo-Joshi added enhancement ℹ️ good-first-issue information: good-first-issue labels Jan 15, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jan 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ℹ️ good-first-issue information: good-first-issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant