Skip to content

[FEATURE] Make tg.Bot comparable #2319

Closed
@Bibo-Joshi

Description

@Bibo-Joshi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions