core: prioritize processing commands over processing all other messages
This commit is contained in:
parent
f591c8d54a
commit
807dee5af1
12
main.py
12
main.py
|
@ -15,6 +15,8 @@ DELAY_AFTER_RESPONSE = 3
|
||||||
DELAY_AFTER_MESSAGE = 0.1
|
DELAY_AFTER_MESSAGE = 0.1
|
||||||
DELAY_AFTER_IDLE = 1.0
|
DELAY_AFTER_IDLE = 1.0
|
||||||
|
|
||||||
|
lock = threading.Lock()
|
||||||
|
|
||||||
# some functions that increase readability of the code
|
# some functions that increase readability of the code
|
||||||
def readfile(filename):
|
def readfile(filename):
|
||||||
try:
|
try:
|
||||||
|
@ -272,8 +274,14 @@ def queue_processor():
|
||||||
|
|
||||||
# telegram bot processor
|
# telegram bot processor
|
||||||
def message_handler(update, context):
|
def message_handler(update, context):
|
||||||
print("[DEBUG] Received new message") # just for testing
|
global lock
|
||||||
message_queue.append(update.message)
|
with lock:
|
||||||
|
if update.message.text.__class__ == str and update.message.text.startswith("$"):
|
||||||
|
print("[DEBUG] Received new message with high priority") # just for testing
|
||||||
|
message_queue.insert(0, update.message)
|
||||||
|
else:
|
||||||
|
print("[DEBUG] Received new message") # just for testing
|
||||||
|
message_queue.append(update.message)
|
||||||
|
|
||||||
|
|
||||||
# --- Final stage ---
|
# --- Final stage ---
|
||||||
|
|
Loading…
Reference in New Issue