Bugfix: delete msg from queue, error in whitelist config

This commit is contained in:
gpkvt 2022-08-10 22:25:15 +02:00
parent 88c6c0d436
commit 71cba396e3
1 changed files with 13 additions and 9 deletions

22
tts.py
View File

@ -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