Skip to content
This repository has been archived by the owner on Sep 30, 2022. It is now read-only.

Commit

Permalink
Fix a set error
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulSonOfLars committed Apr 12, 2018
1 parent 2573e75 commit e5e6ef4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tg_bot/modules/sql/blacklist_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.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()
Expand All @@ -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():
Expand Down

0 comments on commit e5e6ef4

Please sign in to comment.