mini_apps.app
- class mini_apps.app.App(settings, name=None)
Bases:
LogSource
Contains boilerplate code to manage the various connections Inherit from this and override the relevant methods to implement your own app
- static bot_command(*args, **kwargs)
Decorator that automatically registers methods as commands
- Parameters:
trigger – Command trigger
description – Command description as shown in the bot menu
- decode_telegram_data(data: str)
Decodes data as per https://core.telegram.org/bots/webapps#validating-data-received-via-the-mini-app
- get_user(message: dict)
Called to authenticate a user based on the mini app initData Return None if authentication fails, otherwise return a user object
- async login(client: Client, message: dict)
Login logic
- Parameters:
client – Client requesting to log in
message – Data as sent from the client
- on_server_start()
Called when the server starts
- async on_telegram_callback(event: CallbackQuery)
Called on button presses on the telegram bot
- async on_telegram_callback_raw(event: CallbackQuery)
Called on telegram callback queries (inline button presses), just wraps on_telegram_callback() with exception handling for convenience
- async on_telegram_command(trigger: str, args: str, event: NewMessage)
Called on a telegram /command
- Returns:
True if the command has been handled
- async on_telegram_connected()
Called when the connection to the telegram bot is established
- async on_telegram_exception(exception: Exception)
Called when there is an exception on the telegram connection
- async on_telegram_inline(event: InlineQuery)
Called on telegram bot inline queries
- async on_telegram_inline_raw(event: InlineQuery)
Called on telegram inline queries, just wraps on_telegram_inline() with exception handling for convenience
- async on_telegram_message(event: NewMessage)
Called on messages sent to the telegram bot
- async on_telegram_message_raw(event: NewMessage)
Called on messages sent to the telegram bot wraps on_telegram_message() for convenience and detects bot /commands
- register_models()
Override in derived classes to register the models in self.settings.database_models
- async run_bot()
Runs the telegram bot
- async send_telegram_commands()
Automatically sends the registered commands
- server_tasks()
Returns any extra async tasks needed to run the app
- class mini_apps.app.BotStatus(value)
Bases:
Enum
Enumeration that describe the status of a telegram bot
- class mini_apps.app.MetaBot(name, bases, attrs)
Bases:
type
Metaclass for telegram bot to allow automatic registration of commands from methods
- class mini_apps.app.SettingsListUserFilter(banned, admins)
Bases:
UserFilter
Ban/admin list filter
- filter_user(user)
Filter users
Users in the ban list will not be connected, users in the admin list will be marked as admins