TelegramBot
- class TelegramBot[source]
Bases:
TelegramBotBaseA Telegram Bot for controlling and monitoring the village system.
- token
The Telegram bot token.
- Type:
str
- chat
The chat ID to send alarms to.
- Type:
str
- message
Current message buffer.
- Type:
str
- connected
Connection status.
- Type:
bool
- error_running
Flag indicating if an error occurred during the loop.
- Type:
bool
- error
Error message.
- Type:
str
- thread
Background thread for the bot loop.
- Type:
threading.Thread
- application
The python-telegram-bot application instance.
- Type:
Application
- __init__() None[source]
Initializes the TelegramBot and starts the background loop.
Methods
__init__()Initializes the TelegramBot and starts the background loop.
alarm(message)Sends an alarm message to the configured chat.
botloop()Entry point for the bot thread.
Starts the main bot task.
cam(update, context)Takes pictures from cameras and sends them.
main()Main asyncio loop for the bot application.
plot(update, context)Generates and sends a plot of corridor events.
report(update, context)Generates and sends a report for the specified number of hours.
start(update, context)Responds to the /start command.
Attributes
- error: str = 'Error connecting to the telegram_bot '
- async start(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE) None[source]
Responds to the /start command.
- Parameters:
update (Update) – The update object.
context (ContextTypes.DEFAULT_TYPE) – The context object.
- alarm(message: str) None[source]
Sends an alarm message to the configured chat.
- Parameters:
message (str) – The message content.
- async report(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE) None[source]
Generates and sends a report for the specified number of hours.
- Parameters:
update (Update) – The update object.
context (ContextTypes.DEFAULT_TYPE) – The context object (contains args).
- async cam(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE) None[source]
Takes pictures from cameras and sends them.
- Parameters:
update (Update) – The update object.
context (ContextTypes.DEFAULT_TYPE) – The context object.
- async plot(update: telegram.Update, context: telegram.ext.ContextTypes.DEFAULT_TYPE) None[source]
Generates and sends a plot of corridor events.
- Parameters:
update (Update) – The update object.
context (ContextTypes.DEFAULT_TYPE) – The context object.
- async main() None[source]
Main asyncio loop for the bot application.
- async botloop_starttask() None[source]
Starts the main bot task.
- botloop() None[source]
Entry point for the bot thread.