zhenxun_bot/plugins/genshin/almanac/__init__.py

69 lines
2.0 KiB
Python
Raw Normal View History

2022-12-31 17:15:14 +08:00
from configs.config import Config
from configs.path_config import IMAGE_PATH
2021-05-20 19:31:25 +08:00
from nonebot import on_command
2022-02-19 18:20:19 +08:00
from nonebot.adapters.onebot.v11 import GroupMessageEvent, MessageEvent
2021-05-20 19:31:25 +08:00
from services.log import logger
2021-10-03 14:24:07 +08:00
from utils.manager import group_manager
2022-12-31 17:15:14 +08:00
from utils.message_builder import image
from utils.utils import get_bot, scheduler
from ._data_source import build_alc_image
2021-05-20 19:31:25 +08:00
2021-10-03 14:24:07 +08:00
__zx_plugin_name__ = "原神老黄历"
__plugin_usage__ = """
usage
有时候也该迷信一回特别是运气方面
指令
原神黄历
""".strip()
__plugin_des__ = "有时候也该迷信一回!特别是运气方面"
__plugin_cmd__ = ["原神黄历"]
__plugin_type__ = ("原神相关",)
__plugin_version__ = 0.1
__plugin_author__ = "HibiKier"
__plugin_settings__ = {
"level": 5,
"default_status": True,
"limit_superuser": False,
"cmd": ["原神黄历", "原神老黄历"],
}
__plugin_task__ = {"genshin_alc": "原神黄历提醒"}
2021-05-20 19:31:25 +08:00
2021-12-16 11:16:28 +08:00
Config.add_plugin_config(
"_task",
"DEFAULT_GENSHIN_ALC",
True,
help_="被动 原神黄历提醒 进群默认开关状态",
default_value=True,
)
2022-12-31 17:15:14 +08:00
almanac = on_command("原神黄历", priority=5, block=True)
2021-05-20 19:31:25 +08:00
@almanac.handle()
2022-12-31 17:15:14 +08:00
async def _(event: MessageEvent):
await almanac.send(image(b64=await build_alc_image()))
logger.info(
f"(USER {event.user_id}, GROUP {event.group_id if isinstance(event, GroupMessageEvent) else 'private'})"
f" 发送查看原神黄历"
)
2021-05-20 19:31:25 +08:00
@scheduler.scheduled_job(
2021-07-30 21:21:51 +08:00
"cron",
2021-05-20 19:31:25 +08:00
hour=10,
minute=25,
)
async def _():
# 每日提醒
bot = get_bot()
2021-10-03 14:24:07 +08:00
if bot:
gl = await bot.get_group_list()
gl = [g["group_id"] for g in gl]
2022-12-31 17:15:14 +08:00
alc_img = image(b64=await build_alc_image())
2021-11-23 21:44:59 +08:00
if alc_img:
2022-12-31 17:15:14 +08:00
mes = "[[_task|genshin_alc]]" + alc_img
2021-11-23 21:44:59 +08:00
for gid in gl:
2022-11-21 20:43:41 +08:00
if group_manager.check_group_task_status(gid, "genshin_alc"):
2021-12-01 14:03:34 +08:00
await bot.send_group_msg(group_id=int(gid), message="" + mes)