Add module.

This commit is contained in:
2021-09-12 11:37:07 +03:00
parent 70fa80fe29
commit a316775cad
7 changed files with 1087 additions and 0 deletions

26
bot/modules/study/data.py Normal file
View File

@@ -0,0 +1,26 @@
from cachetools import cached
from data import Table, RowTable
untracked_channels = Table('untracked_channels')
study_badges = RowTable(
'study_badges',
('badgeid', 'guildid', 'roleid', 'required_time'),
'badgeid'
)
current_study_badges = Table('current_study_badges')
new_study_badges = Table('new_study_badges')
# Cache of study role ids attached to each guild. Not automatically updated.
guild_role_cache = {} # guildid -> set(roleids)
@study_badges.save_query
@cached(guild_role_cache)
def for_guild(guildid):
rows = study_badges.fetch_rows_where(guildid=guildid)
return set(row.roleid for row in rows)