commands

Attributes

logger

Logger for the Command Handler service module

API_TOKEN

The API token for the Telegram bot, retrieved from the configuration file.

BOT_USERNAME

The username of the Telegram bot, retrieved from the configuration file.

P_HTML

Parse mode set to HTML for formatting Telegram messages.

Functions

verify_condition(→ Callable)

Decorator to verify conditions before executing bot commands.

start_command(→ telegram.Message)

Handle the /start command for the Telegram bot.

info_command(→ telegram.Message)

Handle the /info command, providing information about bot usage.

addcontact_command(→ telegram.Message)

Handle the /addcontact command, allowing users to add emergency contacts.

showcontacts_command(→ telegram.Message)

Handle the /showcontacts command, displaying the user's emergency contacts.

delcontact_command(→ telegram.Message)

Handle the /delcontact command, allowing users to delete emergency contacts.

addverif_command(→ telegram.Message)

Handle the /addverif command, allowing users to add daily verification messages.

showverifs_command(→ telegram.Message)

Handle the /showverifs command, displaying the user's daily verification messages.

delverif_command(→ telegram.Message)

Handle the /delverif command, allowing users to delete daily verification messages.

skip_command(→ telegram.Message)

Handle the /skip command, allowing users to skip the next daily verification.

undoskip_command(→ telegram.Message)

Handle the /undoskip command, allowing users to undo skipped daily verifications.

bugreport_command(→ telegram.Message)

Handle the /bugreport command, allowing users to report bugs or suggest improvements.

request_command(→ telegram.Message)

Handle the /request command, showing and processing association requests.

fastcheck_command(→ telegram.Message)

Handle the /fastcheck command, allowing users to set up a quick verification.

help_command(→ telegram.Message)

Handle the /help command, allowing users to notify emergency contacts.

undohelp_command(→ telegram.Message)

Handle the /undohelp command, allowing users to cancel the alert state.

empty_command(→ telegram.Message)

Handle the /empty command, canceling the current operation.

kill_user_data(→ telegram.Message)

Handle the command to delete all user data.

Module Contents

logger

Logger for the Command Handler service module

API_TOKEN

The API token for the Telegram bot, retrieved from the configuration file.

BOT_USERNAME

The username of the Telegram bot, retrieved from the configuration file.

P_HTML

Parse mode set to HTML for formatting Telegram messages.

verify_condition(func: Callable) Callable

Decorator to verify conditions before executing bot commands.

This decorator checks if: 1. The message is from a group (not supported) 2. The user has a username (required)

If conditions are not met, appropriate messages are sent to the user.

Parameters:

func (Callable) – The function to be decorated.

Returns:

The wrapped function.

Return type:

Callable

async start_command(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE, **kwargs) telegram.Message

Handle the /start command for the Telegram bot.

This function: 1. Checks if the user is already registered 2. Registers new users 3. Processes any pending contact requests for the user 4. Sends a welcome message

Parameters:
  • update (Update) – The incoming update.

  • context (ContextTypes.DEFAULT_TYPE) – The context object for the update.

  • **kwargs – Additional keyword arguments.

Returns:

Response message from the bot.

Return type:

Message

async info_command(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE, **kwargs) telegram.Message

Handle the /info command, providing information about bot usage.

Parameters:
  • update (Update) – The incoming update.

  • context (ContextTypes.DEFAULT_TYPE) – The context object for the update.

  • **kwargs – Additional keyword arguments.

Returns:

Response message from the bot.

Return type:

Message

async addcontact_command(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE, **kwargs) telegram.Message

Handle the /addcontact command, allowing users to add emergency contacts.

Parameters:
  • update (Update) – The incoming update.

  • context (ContextTypes.DEFAULT_TYPE) – The context object for the update.

  • **kwargs – Additional keyword arguments.

Returns:

Response message from the bot.

Return type:

Message

async showcontacts_command(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE, **kwargs) telegram.Message

Handle the /showcontacts command, displaying the user’s emergency contacts.

Parameters:
  • update (Update) – The incoming update.

  • context (ContextTypes.DEFAULT_TYPE) – The context object for the update.

  • **kwargs – Additional keyword arguments.

Returns:

Response message from the bot.

Return type:

Message

async delcontact_command(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE, **kwargs) telegram.Message

Handle the /delcontact command, allowing users to delete emergency contacts.

Parameters:
  • update (Update) – The incoming update.

  • context (ContextTypes.DEFAULT_TYPE) – The context object for the update.

  • **kwargs – Additional keyword arguments.

Returns:

Response message from the bot.

Return type:

Message

async addverif_command(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE, **kwargs) telegram.Message

Handle the /addverif command, allowing users to add daily verification messages.

Parameters:
  • update (Update) – The incoming update.

  • context (ContextTypes.DEFAULT_TYPE) – The context object for the update.

  • **kwargs – Additional keyword arguments.

Returns:

Response message from the bot.

Return type:

Message

async showverifs_command(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE, **kwargs) telegram.Message

Handle the /showverifs command, displaying the user’s daily verification messages.

Parameters:
  • update (Update) – The incoming update.

  • context (ContextTypes.DEFAULT_TYPE) – The context object for the update.

  • **kwargs – Additional keyword arguments.

Returns:

Response message from the bot.

Return type:

Message

async delverif_command(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE, **kwargs) telegram.Message

Handle the /delverif command, allowing users to delete daily verification messages.

Parameters:
  • update (Update) – The incoming update.

  • context (ContextTypes.DEFAULT_TYPE) – The context object for the update.

  • **kwargs – Additional keyword arguments.

Returns:

Response message from the bot.

Return type:

Message

async skip_command(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE, **kwargs) telegram.Message

Handle the /skip command, allowing users to skip the next daily verification.

Parameters:
  • update (Update) – The incoming update.

  • context (ContextTypes.DEFAULT_TYPE) – The context object for the update.

  • **kwargs – Additional keyword arguments.

Returns:

Response message from the bot.

Return type:

Message

async undoskip_command(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE, **kwargs) telegram.Message

Handle the /undoskip command, allowing users to undo skipped daily verifications.

Parameters:
  • update (Update) – The incoming update.

  • context (ContextTypes.DEFAULT_TYPE) – The context object for the update.

  • **kwargs – Additional keyword arguments.

Returns:

Response message from the bot.

Return type:

Message

async bugreport_command(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE, **kwargs) telegram.Message

Handle the /bugreport command, allowing users to report bugs or suggest improvements.

Parameters:
  • update (Update) – The incoming update.

  • context (ContextTypes.DEFAULT_TYPE) – The context object for the update.

  • **kwargs – Additional keyword arguments.

Returns:

Response message from the bot.

Return type:

Message

async request_command(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE, quiet: bool = False, **kwargs) telegram.Message

Handle the /request command, showing and processing association requests.

Parameters:
  • update (Update) – The incoming update.

  • context (ContextTypes.DEFAULT_TYPE) – The context object for the update.

  • quiet (bool) – If True, don’t send a message if there are no requests.

  • **kwargs – Additional keyword arguments.

Returns:

Response message from the bot.

Return type:

Message

async fastcheck_command(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE, **kwargs) telegram.Message

Handle the /fastcheck command, allowing users to set up a quick verification.

Parameters:
  • update (Update) – The incoming update.

  • context (ContextTypes.DEFAULT_TYPE) – The context object for the update.

  • **kwargs – Additional keyword arguments.

Returns:

Response message from the bot.

Return type:

Message

async help_command(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE, **kwargs) telegram.Message

Handle the /help command, allowing users to notify emergency contacts.

Parameters:
  • update (Update) – The incoming update.

  • context (ContextTypes.DEFAULT_TYPE) – The context object for the update.

  • **kwargs – Additional keyword arguments.

Returns:

Response message from the bot.

Return type:

Message

async undohelp_command(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE, **kwargs) telegram.Message

Handle the /undohelp command, allowing users to cancel the alert state.

Parameters:
  • update (Update) – The incoming update.

  • context (ContextTypes.DEFAULT_TYPE) – The context object for the update.

  • **kwargs – Additional keyword arguments.

Returns:

Response message from the bot.

Return type:

Message

async empty_command(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE, **kwargs) telegram.Message

Handle the /empty command, canceling the current operation.

Parameters:
  • update (Update) – The incoming update.

  • context (ContextTypes.DEFAULT_TYPE) – The context object for the update.

  • **kwargs – Additional keyword arguments.

Returns:

Response message from the bot.

Return type:

Message

async kill_user_data(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE, **kwargs) telegram.Message

Handle the command to delete all user data.

Parameters:
  • update (Update) – The incoming update.

  • context (ContextTypes.DEFAULT_TYPE) – The context object for the update.

  • **kwargs – Additional keyword arguments.

Returns:

Response message from the bot.

Return type:

Message