This repository has been archived on 2024-07-28. You can view files and clone it, but cannot push or open issues or pull requests.
moderator-bot/utils/reload_users.py

32 lines
924 B
Python
Raw Normal View History

2023-01-04 15:14:32 -05:00
async def reload_users_data():
import config
from database import Member
from load import tgc, bot
members = await tgc.members_list(config.group_id)
for member in members:
user = Member.get_or_none(Member.user_id == member["id"])
first_name = member["first_name"]
if (not first_name):
first_name = "NULL"
if (not user):
Member.create(
user_id = member["id"],
first_name = first_name,
username = member["username"],
)
else:
user.first_name = first_name
user.username = member["username"]
user.save()
group = await bot.get_chat(config.group_id)
group_permissions = dict(group["permissions"])
for permission in group_permissions.keys():
config.group_permissions[permission] = group_permissions[permission]