react_chatbot ============= .. py:module:: react_chatbot Attributes ---------- .. autoapisummary:: react_chatbot.logger react_chatbot.API_TOKEN react_chatbot.BOT_USERNAME react_chatbot.bot react_chatbot.DISCORD_API_TOKEN react_chatbot.DISCORD_CHANNEL_ID react_chatbot.discord_client Functions --------- .. autoapisummary:: react_chatbot.on_ready react_chatbot.debug_logger react_chatbot.sub_debug_logger react_chatbot.send_hope_message react_chatbot.notif_pairing_invitation react_chatbot.process_contacts react_chatbot.process_verifications react_chatbot.extract_bugreport react_chatbot.process_alarm react_chatbot.extract_fastcheck react_chatbot.state_dispatcher react_chatbot.handle_messages react_chatbot.error react_chatbot.manual_help react_chatbot.manual_undohelp react_chatbot.button react_chatbot.run_api Module Contents --------------- .. py:data:: logger Logger for the React Chatbot service module .. py:data:: API_TOKEN The API token for the Telegram bot, retrieved from the configuration file. .. py:data:: BOT_USERNAME The username of the Telegram bot, retrieved from the configuration file. .. py:data:: bot The Telegram bot object used to send messages and interact with users. .. py:data:: DISCORD_API_TOKEN The API token for the Discord bot, retrieved from the configuration file. .. py:data:: DISCORD_CHANNEL_ID The Discord channel ID for sending bug reports to developers. .. py:data:: discord_client The Discord bot object used to send the bug reports to developers. .. py:function:: on_ready() :async: Event handler for the Discord bot's 'on_ready' event. .. py:function:: 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. :param func: The asynchronous function to be decorated. :type func: coroutine :returns: The wrapped asynchronous function that logs the debug message before executing the original function. :rtype: coroutine .. py:function:: 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. :param func: The asynchronous function to be decorated. :type func: coroutine :returns: The wrapped asynchronous function that logs the indented debug message before executing the original function. :rtype: coroutine .. py:function:: send_hope_message(update: telegram.Update) -> telegram.Message :async: Send a message indicating that the alert status has been reset. .. py:function:: notif_pairing_invitation(update: telegram.Update, notif_details: list) -> None :async: Send notification to users about a pairing invitation. :param update: The update object from Telegram. :type update: Update :param notif_details: List of notification details. :type notif_details: list .. py:function:: process_contacts(update: telegram.Update, content: str, action: str) -> telegram.Message :async: Process adding or deleting contacts. :param update: The update object from Telegram. :type update: Update :param content: The message content containing contact information. :type content: str :param action: The action to perform ('add' or 'del'). :type action: str .. py:function:: process_verifications(update: telegram.Update, content: str, action: str) -> telegram.Message :async: Process adding or deleting verifications. :param update: The update object from Telegram. :type update: Update :param content: The message content containing verification information. :type content: str :param action: The action to perform ('add' or 'del'). :type action: str .. py:function:: extract_bugreport(update: telegram.Update, content: str) -> telegram.Message | None :async: Extract and save a bug report. Send it to Discord if enabled. :param update: The update object from Telegram. :type update: Update :param content: The bug report content. :type content: str .. py:function:: process_alarm(update: telegram.Update, content: str, action: str) -> telegram.Message :async: Process skipping or undoing skip for alarms. :param update: The update object from Telegram. :type update: Update :param content: The message content containing alarm information. :type content: str :param action: The action to perform ('skip' or 'undoskip'). :type action: str .. py:function:: extract_fastcheck(update: telegram.Update, content: str) -> telegram.Message :async: Extract and process a fast check request. :param update: The update object from Telegram. :type update: Update :param content: The message content containing fast check information. :type content: str .. py:function:: state_dispatcher(update: telegram.Update, state: str, message_body: str) -> telegram.Message :async: Dispatch the appropriate function based on the current state. :param update: The update object from Telegram. :type update: Update :param state: The current state of the conversation. :type state: str :param message_body: The message content. :type message_body: str .. py:function:: handle_messages(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE, **kwargs) -> telegram.Message :async: Handle incoming messages and route them to the appropriate function. :param update: The update object from Telegram. :type update: Update :param context: The context object for the handler. :type context: ContextTypes.DEFAULT_TYPE .. py:function:: error(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE) -> None :async: Log errors caused by updates. .. py:function:: manual_help(user_id: int, username: str) -> None :async: Send a manual help alert to user's contacts. :param user_id: The user's ID. :type user_id: int :param username: The user's username. :type username: str .. py:function:: manual_undohelp(user_id: int, username: str) -> None :async: Send a manual undo help alert to user's contacts. :param user_id: The user's ID. :type user_id: int :param username: The user's username. :type username: str .. py:function:: button(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE) -> telegram.Message :async: Handle button callback queries. :param update: The update object from Telegram. :type update: Update :param context: The context object for the handler. :type context: ContextTypes.DEFAULT_TYPE .. py:function:: run_api() Initialize and run the Telegram bot.