Skip to content

[FEATURE] Infere bot commands from CommandHandler and set them automatically #1859

@Bibo-Joshi

Description

@Bibo-Joshi

Is your feature request related to a problem? Please describe.

Even with API 4.7s new Bot.set_my_commands, setting commands will be tiresome

Describe the solution you'd like

  • Add description attribute to CommandHandler
  • Add Disptacher.set_commands(update=False, delete=False, add=True) that
    • gets the bots command from the registered CommandHandlers
    • Checks that they are valid for BotCommand and set_my_commands
    • gets current commands
    • sets new commands with options:
      • update: If False don't change a command if already set
      • delete: If True, delete commands that were set but currently don't have a corresponding handler
      • add: If False and currently commands are set, doesn't add new ones

Describe alternatives you've considered

Tiresome handwork

Additional context

Bot.set_my_commands is very new, so maybe wait till the next API update to make sure Telegram doesn't change the methods directly

Metadata

Metadata

Assignees

Labels

⚙️ bot-apiaffected functionality: bot-api

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions