Push Notifications¶
-
misbot.push_notifications.get_user_list()¶ Retrieves the
chatIDof all users fromChattable. A tuple is returned which is then unpacked into a list by iterating over the tuple.Returns: List of user chat IDs Return type: list
-
misbot.push_notifications.get_bot()¶ Create an instance of the
telegram.bot.Botobject.Returns: Telegram bot object. Return type: telegram.bot.Bot
-
misbot.push_notifications.push_message_threaded(message, user_list)¶ Use
ThreadPoolExecutorto send notification message asynchronously to all users. Before sending the message, we create a record of the sent message in thePushMessageDB model.We pass the
message_uuidgenerated from created the record of the message previously and pass it to thepush_t().After messages have been sent, we bulk commit all the
PushNotificationrecords created withinpush_t()to our database.Parameters: - message (str) – Notification message
- user_list (list) – List of all bot users
Returns: Time taken to send messages and the
message_uuidReturn type: tuple
-
misbot.push_notifications.push_t(bot, message, message_uuid, chat_id)¶ Sends the message to the specified
chat_id. Records themessage_idreceived intoPushNotificationDB Model. Appends the record object tolist_of_objsto be bulk committed after all messages have been sent throughThreadPoolExecutorParameters: - bot (telegram.bot.Bot) – Telegram Bot object
- message (str) – Notification message
- message_uuid (str) – UUID of the notification message created in
push_message_threaded - chat_id (int|str) – 9-Digit unique user ID
-
misbot.push_notifications.delete_threaded(message_id_list, user_list)¶ Use
ThreadPoolExecutorto delete notification message asynchronously for all users.Parameters: - message_id_list (list) – List of message ids stored in our DB.
- user_list (list) – List of all bot users
Returns: Time taken to send all delete requests
Return type: float
-
misbot.push_notifications.delete(bot, message_id, chat_id)¶ Sends a delete request for a particular
chat_idandmessage_idParameters: - bot (telegram.bot.Bot) – Telegram Bot object
- message_id (int) – The message ID for the notification message
- chat_id (int | str) – 9-Digit unique user ID