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-10-03 14:24:07 +08:00
|
|
|
|
__zx_plugin_name__ = "更新色图 [Superuser]"
|
|
|
|
|
|
__plugin_usage__ = """
|
|
|
|
|
|
usage:
|
|
|
|
|
|
更新数据库内存在的色图
|
|
|
|
|
|
指令:
|
|
|
|
|
|
更新色图
|
|
|
|
|
|
""".strip()
|
|
|
|
|
|
__plugin_cmd__ = ["更新色图"]
|
|
|
|
|
|
__plugin_version__ = 0.1
|
|
|
|
|
|
__plugin_author__ = "HibiKier"
|
|
|
|
|
|
__plugin_block_limit__ = {
|
|
|
|
|
|
"rst": "色图正在更新..."
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
update_setu = on_command(
|
|
|
|
|
|
"更新色图", rule=to_me(), permission=SUPERUSER, priority=1, block=True
|
|
|
|
|
|
)
|
2021-05-20 19:25:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@update_setu.handle()
|
|
|
|
|
|
async def _(bot: Bot, event: Event, state: T_State):
|
|
|
|
|
|
if DOWNLOAD_SETU:
|
2021-10-03 14:24:07 +08:00
|
|
|
|
await update_setu.send("开始更新色图...", at_sender=True)
|
|
|
|
|
|
await update_setu.send(await update_setu_img(), at_sender=True)
|
2021-05-20 19:25:51 +08:00
|
|
|
|
else:
|
2021-10-03 14:24:07 +08:00
|
|
|
|
await update_setu.finish("更新色图配置未开启")
|
2021-05-20 19:25:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 更新色图
|
|
|
|
|
|
@scheduler.scheduled_job(
|
2021-10-03 14:24:07 +08:00
|
|
|
|
"cron",
|
2021-05-20 19:25:51 +08:00
|
|
|
|
hour=4,
|
|
|
|
|
|
minute=30,
|
|
|
|
|
|
)
|
|
|
|
|
|
async def _():
|
2021-10-03 14:24:07 +08:00
|
|
|
|
if DOWNLOAD_SETU:
|
2021-05-20 19:25:51 +08:00
|
|
|
|
await update_setu_img()
|