react_chatbot

Attributes

logger

Logger for the React Chatbot 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.

bot

The Telegram bot object used to send messages and interact with users.

DISCORD_API_TOKEN

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

DISCORD_CHANNEL_ID

The Discord channel ID for sending bug reports to developers.

discord_client

The Discord bot object used to send the bug reports to developers.

Functions

on_ready()

Event handler for the Discord bot's 'on_ready' event.

debug_logger(func)

A decorator that logs the entry of an asynchronous function call at the API level.

sub_debug_logger(func)

A decorator that logs the entry of an asynchronous function call at the sub-level

send_hope_message(→ telegram.Message)

Send a message indicating that the alert status has been reset.

notif_pairing_invitation(→ None)

Send notification to users about a pairing invitation.

process_contacts(→ telegram.Message)

Process adding or deleting contacts.

process_verifications(→ telegram.Message)

Process adding or deleting verifications.

extract_bugreport(→ telegram.Message | None)

Extract and save a bug report. Send it to Discord if enabled.

process_alarm(→ telegram.Message)

Process skipping or undoing skip for alarms.

extract_fastcheck(→ telegram.Message)

Extract and process a fast check request.

state_dispatcher(→ telegram.Message)

Dispatch the appropriate function based on the current state.

handle_messages(→ telegram.Message)

Handle incoming messages and route them to the appropriate function.

error(→ None)

Log errors caused by updates.

manual_help(→ None)

Send a manual help alert to user's contacts.

manual_undohelp(→ None)

Send a manual undo help alert to user's contacts.

button(→ telegram.Message)

Handle button callback queries.

run_api()

Initialize and run the Telegram bot.

Module Contents

logger

Logger for the React Chatbot 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.

bot

The Telegram bot object used to send messages and interact with users.

DISCORD_API_TOKEN

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

DISCORD_CHANNEL_ID

The Discord channel ID for sending bug reports to developers.

discord_client

The Discord bot object used to send the bug reports to developers.

async on_ready()

Event handler for the Discord bot’s ‘on_ready’ event.

debug_logger(func)

A decorator that logs the entry of an asynchronous function call at the API level.

This decorator is intended for logging at the API level and provides a simple debug message before calling the decorated function. The message indicates that the API function is being called.

Parameters:

func (coroutine) – The asynchronous function to be decorated.

Returns:

The wrapped asynchronous function that logs the debug message

before executing the original function.

Return type:

coroutine

sub_debug_logger(func)

A decorator that logs the entry of an asynchronous function call at the sub-level (e.g., nested function calls within an API function).

This decorator is intended for logging sub-level function calls and provides an indented debug message before calling the decorated function. The message indicates that a sub-level function is being called, and is indented for clarity.

Parameters:

func (coroutine) – The asynchronous function to be decorated.

Returns:

The wrapped asynchronous function that logs the indented debug

message before executing the original function.

Return type:

coroutine

async send_hope_message(update: telegram.Update) telegram.Message

Send a message indicating that the alert status has been reset.

async notif_pairing_invitation(update: telegram.Update, notif_details: list) None

Send notification to users about a pairing invitation.

Parameters:
  • update (Update) – The update object from Telegram.

  • notif_details (list) – List of notification details.

async process_contacts(update: telegram.Update, content: str, action: str) telegram.Message

Process adding or deleting contacts.

Parameters:
  • update (Update) – The update object from Telegram.

  • content (str) – The message content containing contact information.

  • action (str) – The action to perform (‘add’ or ‘del’).

async process_verifications(update: telegram.Update, content: str, action: str) telegram.Message

Process adding or deleting verifications.

Parameters:
  • update (Update) – The update object from Telegram.

  • content (str) – The message content containing verification information.

  • action (str) – The action to perform (‘add’ or ‘del’).

async extract_bugreport(update: telegram.Update, content: str) telegram.Message | None

Extract and save a bug report. Send it to Discord if enabled.

Parameters:
  • update (Update) – The update object from Telegram.

  • content (str) – The bug report content.

async process_alarm(update: telegram.Update, content: str, action: str) telegram.Message

Process skipping or undoing skip for alarms.

Parameters:
  • update (Update) – The update object from Telegram.

  • content (str) – The message content containing alarm information.

  • action (str) – The action to perform (‘skip’ or ‘undoskip’).

async extract_fastcheck(update: telegram.Update, content: str) telegram.Message

Extract and process a fast check request.

Parameters:
  • update (Update) – The update object from Telegram.

  • content (str) – The message content containing fast check information.

async state_dispatcher(update: telegram.Update, state: str, message_body: str) telegram.Message

Dispatch the appropriate function based on the current state.

Parameters:
  • update (Update) – The update object from Telegram.

  • state (str) – The current state of the conversation.

  • message_body (str) – The message content.

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

Handle incoming messages and route them to the appropriate function.

Parameters:
  • update (Update) – The update object from Telegram.

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

async error(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE) None

Log errors caused by updates.

async manual_help(user_id: int, username: str) None

Send a manual help alert to user’s contacts.

Parameters:
  • user_id (int) – The user’s ID.

  • username (str) – The user’s username.

async manual_undohelp(user_id: int, username: str) None

Send a manual undo help alert to user’s contacts.

Parameters:
  • user_id (int) – The user’s ID.

  • username (str) – The user’s username.

async button(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE) telegram.Message

Handle button callback queries.

Parameters:
  • update (Update) – The update object from Telegram.

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

run_api()

Initialize and run the Telegram bot.