TelegramCommandBase
- class TelegramCommandBase[source]
Bases:
objectBase class for a custom Telegram bot command.
Subclass in the project code directory so it is picked up by import_all. Set command to the slash-command name (no slash) and implement handler. Args after the command arrive in context.args as strings. TelegramBot.register_custom wraps handler in try/except, so an unhandled exception can’t kill the bot; add your own try/except only if you want to reply with a specific error message instead of failing silently. Set description to a short one-line explanation shown by /help.
- __init__()
Methods
Attributes
- command = ''
- description = ''
- async handler(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE) None[source]
Respond to the command.