解密厨来了2
This commit is contained in:
@ -1,9 +1,13 @@
|
||||
from math import ceil
|
||||
from loguru import logger
|
||||
from nonebot_plugin_alconna import Alconna, Args, UniMessage, on_alconna
|
||||
from konabot.common.nb.qq_broadcast import qq_broadcast
|
||||
from konabot.plugins.kona_ph.core.storage import get_today_date
|
||||
from konabot.plugins.kona_ph.manager import PUZZLE_PAGE_SIZE, create_admin_commands, config, puzzle_manager
|
||||
from konabot.common.longtask import DepLongTaskTarget
|
||||
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
|
||||
|
||||
create_admin_commands()
|
||||
|
||||
@ -84,3 +88,14 @@ async def _(target: DepLongTaskTarget, index_id: str = "", page: int = 1):
|
||||
msg = msg.text(f"\n==== 第 {page} 页,共 {count_pages} 页 ====")
|
||||
await target.send_message(msg)
|
||||
|
||||
|
||||
@scheduler.scheduled_job("cron", hour="8")
|
||||
async def _():
|
||||
async with puzzle_manager() as manager:
|
||||
puzzle = manager.get_today_puzzle()
|
||||
if puzzle is not None:
|
||||
logger.info(f"找到了题目 {puzzle.raw_id},发送")
|
||||
await qq_broadcast(config.plugin_puzzle_playgroup, puzzle.get_unimessage())
|
||||
else:
|
||||
logger.info("自动任务:没有找到题目,跳过")
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ from pydantic import BaseModel
|
||||
|
||||
from konabot.common.longtask import DepLongTaskTarget
|
||||
from konabot.common.nb.extract_image import download_image_bytes
|
||||
from konabot.common.nb.qq_broadcast import qq_broadcast
|
||||
from konabot.plugins.kona_ph.core.storage import Puzzle, get_today_date, puzzle_manager
|
||||
|
||||
PUZZLE_PAGE_SIZE = 10
|
||||
@ -322,6 +323,7 @@ def create_admin_commands():
|
||||
p = manager.get_today_puzzle(strong=True)
|
||||
if p is None:
|
||||
return await target.send_message("上架失败了orz,可能是没题了")
|
||||
await qq_broadcast(config.plugin_puzzle_playgroup, p.get_unimessage())
|
||||
return await target.send_message("Ok!")
|
||||
|
||||
return cmd_admin
|
||||
|
||||
Reference in New Issue
Block a user