Members/admins caching is now configurable
This commit is contained in:
parent
25be843cd8
commit
ace71fd6be
@ -42,6 +42,14 @@
|
|||||||
"cache_avatars": {
|
"cache_avatars": {
|
||||||
"interval": 6,
|
"interval": 6,
|
||||||
"enabled": true
|
"enabled": true
|
||||||
|
},
|
||||||
|
"cache_members": {
|
||||||
|
"interval": 30,
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"cache_admins": {
|
||||||
|
"interval": 120,
|
||||||
|
"enabled": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"locations": {
|
"locations": {
|
||||||
|
@ -12,21 +12,23 @@ from modules.database import col_applications, col_sponsorships
|
|||||||
|
|
||||||
scheduler = AsyncIOScheduler()
|
scheduler = AsyncIOScheduler()
|
||||||
|
|
||||||
@scheduler.scheduled_job(trigger="interval", seconds=20)
|
if configGet("enabled", "scheduler", "cache_members"):
|
||||||
async def cache_group_members():
|
@scheduler.scheduled_job(trigger="interval", seconds=configGet("interval", "scheduler", "cache_members"))
|
||||||
list_of_users = []
|
async def cache_group_members():
|
||||||
async for member in app.get_chat_members(configGet("destination_group")):
|
list_of_users = []
|
||||||
list_of_users.append(member.user.id)
|
async for member in app.get_chat_members(configGet("destination_group")):
|
||||||
makedirs("cache", exist_ok=True)
|
list_of_users.append(member.user.id)
|
||||||
jsonSave(list_of_users, f"cache{sep}group_members")
|
makedirs("cache", exist_ok=True)
|
||||||
|
jsonSave(list_of_users, f"cache{sep}group_members")
|
||||||
|
|
||||||
@scheduler.scheduled_job(trigger="interval", seconds=40)
|
if configGet("enabled", "scheduler", "cache_admins"):
|
||||||
async def cache_admins():
|
@scheduler.scheduled_job(trigger="interval", seconds=configGet("interval", "scheduler", "cache_admins"))
|
||||||
list_of_users = []
|
async def cache_admins():
|
||||||
async for member in app.get_chat_members(configGet("admin_group")):
|
list_of_users = []
|
||||||
list_of_users.append(member.user.id)
|
async for member in app.get_chat_members(configGet("admin_group")):
|
||||||
makedirs("cache", exist_ok=True)
|
list_of_users.append(member.user.id)
|
||||||
jsonSave(list_of_users, f"cache{sep}admins")
|
makedirs("cache", exist_ok=True)
|
||||||
|
jsonSave(list_of_users, f"cache{sep}admins")
|
||||||
|
|
||||||
# Cache the avatars of group members
|
# Cache the avatars of group members
|
||||||
if configGet("enabled", "scheduler", "cache_avatars"):
|
if configGet("enabled", "scheduler", "cache_avatars"):
|
||||||
|
Reference in New Issue
Block a user