From 71cba396e339de26944ff780585789d40aa3d315 Mon Sep 17 00:00:00 2001 From: gpkvt Date: Wed, 10 Aug 2022 22:25:15 +0200 Subject: [PATCH] Bugfix: delete msg from queue, error in whitelist config --- tts.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tts.py b/tts.py index a4b36a6..9de70b5 100644 --- a/tts.py +++ b/tts.py @@ -21,7 +21,7 @@ class IRC: def __init__(self): self.irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.tts_denied = [] - if conf['WHITELIST_USER']: + if 'WHITELIST_USER' in conf: self.tts_allowed = conf['WHITELIST_USER'] else: self.tts_allowed = [] @@ -69,20 +69,24 @@ class IRC: logging.info('CLEARMSG received') msgid = False + global msg_queue_raw + filtered_msg_queue = [] + tags = resp.split(';') for tag in tags: if "target-msg-id=" in tag: msgid = tag.rsplit('target-msg-id=',1)[1] logging.debug('Trying to suppress message') - logging.debug(msg) - for key in list(msg_queue_raw.keys()): - logging.debug('key:') - logging.debug(key) - logging.debug('msg_queue_raw:') - logging.debug(msg_queue_raw) - if msg_queue_raw[key]['msgid'] == msg['msgid']: + logging.debug(msgid) + + for msg in list(msg_queue_raw): + pprint(msg) + if msg['msgid'] == msgid: logging.info('Suppressing message '+str(msgid)) - del msg_queue_raw[key] + else: + filtered_msg_queue.append(msg) + + msg_queue_raw = filtered_msg_queue return True