bot package
Submodules
bot.receive_msg module
- class bot.receive_msg.ReceivingMessage(shutdown_event, config, loop, camera_task_queue_async, door_open_task_queue)
Bases:
objectReceiving Telegram Bot messages
- Parameters:
shutdown_event (threading.Event)
config (config_util.Configuration)
camera_task_queue_async (asyncio.Queue)
door_open_task_queue (queue.Queue)
- start()
Starts the bot’s endless polling. Uses the bot’s infinity_polling method with specified timeout and long_polling_timeout. Logs any errors that occur during polling.
- Return type:
None
- stop()
A method to stop the bot. It logs the action of stopping bot polling, stops the bot from polling, removes the webhook, and logs the completion of stopping the bot.
- receive_any_msg_text(message)
Check if the message is received from an allowed telegram chat group and allowed user ID. If the conditions are met, check if the message text has a TOTP code and open the door if correct, otherwise do nothing.
- Parameters:
message (telebot.types.Message): The message object received.
- Returns:
None
- Parameters:
message (telebot.types.Message)
- Return type:
None
- take_foto(message)
Takes a photo request from a telegram message and puts it into a camera task queue.
- Args:
message (telebot.types.Message): The telegram message object containing the photo request.
- Returns:
None
This function first logs a debug message indicating that a photo request has been received with the given message. It then checks if the message is received from an allowed telegram chat group and if it was sent by an allowed user ID. If the conditions are met, it sets the event loop to the current loop and puts a camera task into the camera task queue. The camera task contains the chat ID, message, reply flag, and photo flag.
- Parameters:
message (telebot.types.Message)
- Return type:
None
- take_picam_foto(message)
Takes a photo request specific to the PiCam (foto API [PiCamAPI](https://github.com/OliverDrechsler/PiCam_API)) from a telegram message and puts it into a camera task queue.
- Args:
message (telebot.types.Message): The telegram message object containing the photo request.
- Returns:
None
- Parameters:
message (telebot.types.Message)
- Return type:
None
- take_blink_foto(message)
Takes a photo request specific to the Blink camera from a telegram message and puts it into a camera task queue.
- Args:
message (telebot.types.Message): The telegram message object containing the photo request.
- Returns:
None
This function first logs a debug message indicating that a Blink photo request has been received with the given message. It then checks if the message is received from an allowed telegram chat group and if it was sent by an allowed user ID. If the conditions are met, it sets the event loop to the current loop and puts a camera task into the camera task queue. The camera task contains the chat ID, message, reply flag, and blink_photo flag.
- Parameters:
message (telebot.types.Message)
- Return type:
None
- register_bink_authentication(message)
Registers a Blink authentication based on the received message.
- Args:
self: the object instance message (telebot.types.Message): the message received
- Returns:
None
- Parameters:
message (telebot.types.Message)
- Return type:
None
bot.send_msg module
- class bot.send_msg.SendMessage(shutdown_event, config, loop, message_task_queue)
Bases:
object- Parameters:
shutdown_event (Event)
config (Configuration)
message_task_queue (Queue)
- start()
Starts the thread endless loop to send telegram bot messages.
This function runs in an infinite loop until the stop_polling event is set. It continuously retrieves tasks from the message_task_queue and processes them. If a task is an instance of Message_Task, it performs the following actions based on the task attributes: - If task.send is True, it sends a message to the specified chat using the send_message method. - If task.reply is True, it replies to the specified message with the given text using the reply_message method. - If task.photo is True, it sends a photo to the specified chat using the send_photo method.
If an exception occurs during the execution of the loop, it logs the error and continues.
After the loop finishes, it calls the stop method.
- Parameters:
self (SendMessage): The instance of the SendMessage class.
- Returns:
None
- Return type:
None
- stop()
A method to stop the bot. It logs the action of stopping bot polling, stops the bot from polling, removes the webhook.
- Return type:
None