Skip to content

Commit a093fb8

Browse files
authored
Make sure factoids only appear in the channels they are set in (CloudBotIRC#232)
1 parent ab841bf commit a093fb8

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

plugins/factoids.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,13 @@ def load_cache(db):
3232
:type db: sqlalchemy.orm.Session
3333
"""
3434
global factoid_cache
35-
factoid_cache = defaultdict(lambda: default_dict)
35+
factoid_cache = defaultdict(default_dict.copy)
3636
for row in db.execute(table.select()):
3737
# assign variables
3838
chan = row["chan"]
3939
word = row["word"]
4040
data = row["data"]
41-
if chan not in factoid_cache:
42-
factoid_cache.update({chan: {word: data}})
43-
elif word not in factoid_cache[chan]:
44-
factoid_cache[chan].update({word: data})
45-
else:
46-
factoid_cache[chan][word] = data
41+
factoid_cache[chan][word] = data
4742

4843

4944
def add_factoid(db, word, chan, data, nick):

0 commit comments

Comments
 (0)