mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-08 05:10:01 +08:00
update v0.0.5.0
This commit is contained in:
@@ -5,6 +5,13 @@ from models.group_info import GroupInfo
|
||||
from asyncpg.exceptions import ConnectionDoesNotExistError
|
||||
|
||||
|
||||
__zx_plugin_name__ = '管理方面定时任务 [Hidden]'
|
||||
__plugin_usage__ = '无'
|
||||
__plugin_des__ = '成员信息和管理权限的定时更新'
|
||||
__plugin_version__ = 0.1
|
||||
__plugin_author__ = 'HibiKier'
|
||||
|
||||
|
||||
# 自动更新群员信息
|
||||
@scheduler.scheduled_job(
|
||||
"cron",
|
||||
@@ -13,14 +20,15 @@ from asyncpg.exceptions import ConnectionDoesNotExistError
|
||||
)
|
||||
async def _():
|
||||
bot = get_bot()
|
||||
gl = await bot.get_group_list(self_id=bot.self_id)
|
||||
gl = [g["group_id"] for g in gl]
|
||||
for g in gl:
|
||||
try:
|
||||
await update_member_info(g)
|
||||
logger.info(f"更新群组 g:{g} 成功")
|
||||
except Exception as e:
|
||||
logger.error(f"更新群组错误 g:{g} e:{e}")
|
||||
if bot:
|
||||
gl = await bot.get_group_list()
|
||||
gl = [g["group_id"] for g in gl]
|
||||
for g in gl:
|
||||
try:
|
||||
await update_member_info(g)
|
||||
logger.info(f"更新群组 g:{g} 成功")
|
||||
except Exception as e:
|
||||
logger.error(f"更新群组错误 g:{g} e:{e}")
|
||||
|
||||
|
||||
# 快速更新群员信息以及管理员权限
|
||||
@@ -31,12 +39,13 @@ async def _():
|
||||
async def _():
|
||||
try:
|
||||
bot = get_bot()
|
||||
gl = await bot.get_group_list(self_id=bot.self_id)
|
||||
gl = [g["group_id"] for g in gl]
|
||||
all_group = [x.group_id for x in await GroupInfo.get_all_group()]
|
||||
for g in gl:
|
||||
if g not in all_group:
|
||||
await update_member_info(g)
|
||||
logger.info(f"快速更新群信息以及权限:{g}")
|
||||
if bot:
|
||||
gl = await bot.get_group_list()
|
||||
gl = [g["group_id"] for g in gl]
|
||||
all_group = [x.group_id for x in await GroupInfo.get_all_group()]
|
||||
for g in gl:
|
||||
if g not in all_group:
|
||||
await update_member_info(g)
|
||||
logger.info(f"快速更新群信息以及权限:{g}")
|
||||
except (IndexError, ConnectionDoesNotExistError):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user