mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-05 03:39:59 +08:00
✨ 更新群组信息
This commit is contained in:
@@ -23,17 +23,15 @@ async def _(bot: Bot):
|
||||
if PlatformUtils.get_platform(bot) == "qq":
|
||||
logger.debug(f"更新Bot: {bot.self_id} 的群认证...")
|
||||
group_list, _ = await PlatformUtils.get_group_list(bot)
|
||||
gid_list = [(g.group_id, g.group_name) for g in group_list]
|
||||
db_group_list = await GroupConsole.all().values_list("group_id", flat=True)
|
||||
create_list = []
|
||||
update_id = []
|
||||
for gid, name in gid_list:
|
||||
if gid not in db_group_list:
|
||||
create_list.append(
|
||||
GroupConsole(group_id=gid, group_name=name, group_flag=1)
|
||||
)
|
||||
for group in group_list:
|
||||
if group.group_id not in db_group_list:
|
||||
group.group_flag = 1
|
||||
create_list.append(group)
|
||||
else:
|
||||
update_id.append(gid)
|
||||
update_id.append(group.group_id)
|
||||
if create_list:
|
||||
await GroupConsole.bulk_create(create_list, 10)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user