zhenxun_bot/plugins/update_setu/__init__.py

45 lines
1.2 KiB
Python
Raw Normal View History

2021-06-30 19:50:55 +08:00
from utils.utils import scheduler
2021-05-20 19:25:51 +08:00
from nonebot import on_command
from nonebot.permission import SUPERUSER
from nonebot.typing import T_State
from nonebot.adapters import Bot, Event
from nonebot.rule import to_me
from .data_source import update_setu_img
from configs.config import DOWNLOAD_SETU
2021-06-15 10:57:08 +08:00
__plugin_name__ = "更新色图 [Hidden]"
__plugin_usage__ = ''
2021-05-20 19:25:51 +08:00
2021-08-04 15:19:45 +08:00
exists_flag = False
2021-05-20 19:25:51 +08:00
update_setu = on_command("更新色图", rule=to_me(), permission=SUPERUSER, priority=1, block=True)
@update_setu.handle()
async def _(bot: Bot, event: Event, state: T_State):
2021-08-04 15:19:45 +08:00
global exists_flag
2021-05-20 19:25:51 +08:00
if DOWNLOAD_SETU:
2021-08-04 15:19:45 +08:00
if not exists_flag:
exists_flag = True
await update_setu.send("开始更新色图...", at_sender=True)
await update_setu.send(await update_setu_img(), at_sender=True)
exists_flag = False
else:
await update_setu.finish("色图正在更新....")
2021-05-20 19:25:51 +08:00
else:
await update_setu.finish('更新色图配置未开启')
# 更新色图
@scheduler.scheduled_job(
'cron',
hour=4,
minute=30,
)
async def _():
2021-08-04 15:19:45 +08:00
global exists_flag
if DOWNLOAD_SETU and not exists_flag:
2021-05-20 19:25:51 +08:00
await update_setu_img()