Skip to content

Commit cd33b0c

Browse files
committed
Fix grab cache loading
1 parent 5d9634c commit cd33b0c

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

plugins/grab.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,20 @@
1717
Column('chan', String)
1818
)
1919

20+
grab_cache = {}
21+
22+
2023
@hook.on_start()
2124
def load_cache(db):
2225
"""
2326
:type db: sqlalchemy.orm.Session
2427
"""
25-
global grab_cache
26-
grab_cache = {}
28+
grab_cache.clear()
2729
for row in db.execute(table.select().order_by(table.c.time)):
2830
name = row["name"].lower()
2931
quote = row["quote"]
3032
chan = row["chan"]
31-
if chan not in grab_cache:
32-
grab_cache.update({chan:{name:[chan]}})
33-
elif name not in grab_cache[chan]:
34-
grab_cache[chan].update({name:[quote]})
35-
else:
36-
grab_cache[chan][name].append(quote)
33+
grab_cache.setdefault(chan, {}).setdefault(name, []).append(quote)
3734

3835
def two_lines(bigstring, chan):
3936
"""Receives a string with new lines. Groups the string into a list of strings with up to 3 new lines per string element. Returns first string element then stores the remaining list in search_pages."""

0 commit comments

Comments
 (0)