From 141da380e0ddd877ea0869f8924e9c3dbe1db769 Mon Sep 17 00:00:00 2001 From: Paul Larsen Date: Thu, 12 Apr 2018 10:31:24 +0100 Subject: [PATCH] Fix a set error --- tg_bot/modules/sql/blacklist_sql.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tg_bot/modules/sql/blacklist_sql.py b/tg_bot/modules/sql/blacklist_sql.py index 5090824d7..e4d6b9dd2 100644 --- a/tg_bot/modules/sql/blacklist_sql.py +++ b/tg_bot/modules/sql/blacklist_sql.py @@ -36,15 +36,15 @@ def add_to_blacklist(chat_id, trigger): SESSION.merge(blacklist_filt) # merge to avoid duplicate key issues SESSION.commit() - CHAT_BLACKLISTS[str(chat_id)] = CHAT_BLACKLISTS.get(str(chat_id), []).append(trigger) + CHAT_BLACKLISTS[str(chat_id)] = CHAT_BLACKLISTS.get(str(chat_id), set()).add(trigger) def rm_from_blacklist(chat_id, trigger): with BLACKLIST_FILTER_INSERTION_LOCK: blacklist_filt = SESSION.query(BlackListFilters).get((str(chat_id), trigger)) if blacklist_filt: - if trigger in CHAT_BLACKLISTS.get(str(chat_id), []): # sanity check - CHAT_BLACKLISTS.get(str(chat_id), []).remove(trigger) + if trigger in CHAT_BLACKLISTS.get(str(chat_id), set()): # sanity check + CHAT_BLACKLISTS.get(str(chat_id), set()).remove(trigger) SESSION.delete(blacklist_filt) SESSION.commit() @@ -55,7 +55,7 @@ def rm_from_blacklist(chat_id, trigger): def get_chat_blacklist(chat_id): - return CHAT_BLACKLISTS.get(str(chat_id), []) + return CHAT_BLACKLISTS.get(str(chat_id), set()) def num_blacklist_filters():