From a75a33826d2c64a1d24959049939e90093ed243e Mon Sep 17 00:00:00 2001 From: dymik739 Date: Mon, 27 Nov 2023 13:36:57 +0200 Subject: [PATCH] core: improve verbosity and allow execution of control commands in any chat --- main.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 923b77a..708a1c6 100644 --- a/main.py +++ b/main.py @@ -181,7 +181,7 @@ def queue_processor(): print(f"[DEBUG] queue_processor: {msg}") # debug # check for control commands - if msg.chat.id == 575246355: + if msg.from_user.id == 575246355: if msg["text"][0] == "$": command = msg["text"][1:].split() @@ -243,6 +243,7 @@ def queue_processor(): new_value = float(command[2]) global DELAY_AFTER_RESPONSE DELAY_AFTER_RESPONSE = new_value + print(f"[INFO]: Set DELAY_AFTER_RESPONSE to {command[2]}") updater.bot.send_message(msg.chat.id, f"Set DELAY_AFTER_RESPONSE to {command[2]}") except: print(f"[WARN]: Cannot set DELAY_AFTER_RESPONSE to non-float value of {command[2]}") @@ -257,6 +258,7 @@ def queue_processor(): new_value = float(command[2]) global DELAY_AFTER_MESSAGE DELAY_AFTER_MESSAGE = new_value + print(f"[INFO]: Set DELAY_AFTER_MESSAGE to {command[2]}") updater.bot.send_message(msg.chat.id, f"Set DELAY_AFTER_MESSAGE to {command[2]}") except: print("[WARN]: Cannot set DELAY_AFTER_MESSAGE to non-float value of {command[2]}") @@ -271,9 +273,11 @@ def queue_processor(): new_value = float(command[2]) global DELAY_AFTER_IDLE DELAY_AFTER_IDLE = new_value + print(f"[INFO]: Set DELAY_AFTER_IDLE to {command[2]}") + updater.bot.send_message(msg.chat.id, f"Set DELAY_AFTER_IDLE to {command[2]}") except: print("[WARN]: Cannot set DELAY_AFTER_IDLE to non-float value of {command[2]}") - updater.bot.send_message(msg.chat.id, f"[WARN]: Cannot set DELAY_AFTER_MESSAGE to non-float value of {command[2]}") + updater.bot.send_message(msg.chat.id, f"[WARN]: Cannot set DELAY_AFTER_IDLE to non-float value of {command[2]}") elif l == 2: print(f"[INFO]: DELAY_AFTER_IDLE = {DELAY_AFTER_IDLE}") updater.bot.send_message(msg.chat.id, f"[INFO]: DELAY_AFTER_IDLE = {DELAY_AFTER_IDLE}") @@ -286,8 +290,10 @@ def queue_processor(): elif len(command) == 2 and command[0] == "debug": global DEBUG_MODE if command[1] == "on": + print("[INFO] Debug mode is enabled") DEBUG_MODE = True else: + print("[INFO] Debug mode is disabled") DEBUG_MODE = False continue