diff --git a/module-testing.py b/module-testing.py index 7ac8585..674235c 100644 --- a/module-testing.py +++ b/module-testing.py @@ -6,6 +6,8 @@ import sys import os import threading +from telegram import Message, Chat + # global variables STOP_REQUESTED = False @@ -179,7 +181,6 @@ def queue_processor(): if mod.version == 1: responce = mod.process(msg) if len(responce) > 0: - updater.bot.send_message(chat_id = msg.chat.id, text = responce) print("Responded using module {} ({}) with text: {}".format(mod.path, mod.alias, responce)) break @@ -201,12 +202,6 @@ def queue_processor(): print("[INFO] queue_processor thread stops successfully") -# telegram bot processor -def message_handler(update, context): - print("[DEBUG] Received new message") # just for testing - message_queue.append(update.message) - - # --- Final stage --- @@ -220,25 +215,6 @@ processor_thread = threading.Thread( target = queue_processor, args = [] ) processor_thread.start() -# connecting to Telegram servers and listening for messages -''' -TOKEN = readfile("config/token") -if not TOKEN: - print("[CRIT] Token has not been defined, quitting") - sys.exit(1) - -# connect to Telegram servers -updater = Updater(TOKEN, use_context = True) -dispatcher = updater.dispatcher - -# assign the handler for messages -dispatcher.add_handler(MessageHandler(Filters.text, message_handler)) - -# run the bot -updater.start_polling() -updater.idle() -''' - print("Enter testing messages one by one, end with an empty line") while True: @@ -246,4 +222,4 @@ while True: if len(new_msg) == 0: break - message_queue.append({'text': new_msg, 'new_chat_photo': [], 'message_id': 74, 'new_chat_members': [], 'delete_chat_photo': False, 'group_chat_created': False, 'supergroup_chat_created': False, 'chat': {'first_name': 'Дмитро', 'username': 'dmytrofiot23', 'id': 575246355, 'type': 'private'}, 'caption_entities': [], 'channel_chat_created': False, 'date': 1667585646, 'photo': [], 'entities': [], 'from': {'first_name': 'Дмитро', 'id': 575246355, 'is_bot': False, 'username': 'dmytrofiot23', 'language_code': 'en'}}) + message_queue.append( Message(9, round(time.time()), Chat(575246355, 'supergroup'), text = new_msg) )