refactor: restructure plugins per MTSS standard, consolidate assets to res/
Per docs/plugin-audit-report.md (plugins normalized to Trigger(handlers) → Service(services) → Model(repository/models) + utils): - Split monolithic __init__.py into handlers/services/utils across dailywife, deer_pipe, dice, galgame_card, helldivers_tools, huoziyinshua, learning_chat, makeaquote, mc_server_status, ncm_saying, picfinder_take, picstatus, random_jm_code, regif, steam_info, video_analysis, group_tools - Move static assets under res/: deer_pipe font/img, makeaquote font, helldivers img/templates, huoziyinshua HuoZiYinShua - Add config.py + register_config_items to ncm_saying, random_jm_code, group_tools; learning_chat unified config bridge - Remove deprecated: voice_trans plugin, bf_bot/test.py, dead code in dailywife/deer_pipe, empty dirs, debug scripts under helldivers temp - Disable brash_general_supercredits_tools (stub comment only) - bot.py: optional stdout/stderr redirect to log file for Web log viewer, force ANSI colorize on non-TTY sinks - Move runtime data (jm_code.json) out of plugin dir into hexi/data - Docs: plugin-audit-report.md; README reflects removed plugins Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
from nonebot import on_command
|
||||
from nonebot.adapters.onebot.v11 import MessageEvent, Bot, MessageSegment
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot.rule import to_me
|
||||
"""打卡记鹿 —— 入口(元数据 + 依赖)。"""
|
||||
|
||||
from .data_proc import *
|
||||
from .img_generator import *
|
||||
import io
|
||||
import base64
|
||||
from nonebot import require
|
||||
from nonebot.plugin import PluginMetadata
|
||||
|
||||
require("nonebot_plugin_orm")
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
name="打卡记鹿",
|
||||
@@ -16,54 +13,4 @@ __plugin_meta__ = PluginMetadata(
|
||||
type="application",
|
||||
)
|
||||
|
||||
record = on_command("打卡记鹿", aliases={"打卡"}, rule=to_me())
|
||||
query = on_command("查询记录", aliases={"查卡"})
|
||||
|
||||
|
||||
@record.handle()
|
||||
async def do_job(bot: Bot, ev: MessageEvent):
|
||||
# 获取当前日期的年份和月份
|
||||
now = datetime.now()
|
||||
year = now.year
|
||||
month = now.month
|
||||
# 获取发信人信息
|
||||
uid = str(ev.user_id)
|
||||
message_id = ev.message_id
|
||||
# 添加一条记录
|
||||
await record_month(uid)
|
||||
# 获取记录
|
||||
img = await draw_calendar_grid_image(uid, year, month)
|
||||
text_msg = MessageSegment.text("这是您的打卡记鹿:\n")
|
||||
image_msg = MessageSegment.image(pic2b64(img))
|
||||
mix_msg = (text_msg,)
|
||||
mix_msg += image_msg
|
||||
reply_msg = (MessageSegment.reply(message_id),)
|
||||
reply_msg += mix_msg
|
||||
await record.finish(reply_msg)
|
||||
|
||||
|
||||
def pic2b64(pic: Image) -> str:
|
||||
buf = io.BytesIO()
|
||||
pic.save(buf, format='PNG')
|
||||
base64_str = base64.b64encode(buf.getvalue()).decode()
|
||||
return 'base64://' + base64_str
|
||||
|
||||
|
||||
@query.handle()
|
||||
async def query_job(bot: Bot, ev: MessageEvent):
|
||||
# 获取当前日期的年份和月份
|
||||
now = datetime.now()
|
||||
year = now.year
|
||||
month = now.month
|
||||
# 获取发信人信息
|
||||
uid = str(ev.user_id)
|
||||
message_id = ev.message_id
|
||||
# 获取记录
|
||||
img_file = await draw_calendar_grid_image(uid, year, month)
|
||||
text_msg = MessageSegment.text("这是您的记鹿:\n")
|
||||
image_msg = MessageSegment.image(pic2b64(img_file))
|
||||
mix_msg = (text_msg,)
|
||||
mix_msg += image_msg
|
||||
reply_msg = (MessageSegment.reply(message_id),)
|
||||
reply_msg += mix_msg
|
||||
await record.finish(reply_msg)
|
||||
from .handlers import query, record # noqa: E402,F401
|
||||
|
||||
Reference in New Issue
Block a user