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:
2026-09-03 00:44:38 +08:00
co-authored by Claude
parent 25bc30611f
commit 9371a28e35
2389 changed files with 5100 additions and 10127 deletions
@@ -1,14 +1,10 @@
import httpx
from nonebot import logger, on_command
from nonebot.adapters import Message
from nonebot.matcher import Matcher
from nonebot.params import CommandArg
from nonebot.adapters.onebot.v11 import MessageEvent, Bot, MessageSegment
import re
import json
"""网抑云 —— 入口(元数据 + 依赖 + 配置注册)。"""
from nonebot import require
from nonebot.plugin import PluginMetadata
require("nonebot_plugin_alconna")
__plugin_meta__ = PluginMetadata(
name="网抑云",
description="随机一条网易云热评",
@@ -16,30 +12,7 @@ __plugin_meta__ = PluginMetadata(
type="application",
)
__help_version__ = '0.1.0'
__help_plugin_name__ = "网抑云"
__usage__ = """一开口就老网抑云了
from . import config as _config # noqa: E402
from . import handlers as _handlers # noqa: E402
指令:/网抑云|网易云热评:随机一条网易云热评"""
hitokoto_matcher = on_command("网抑云", aliases={"网易云热评", "emo"})
@hitokoto_matcher.handle()
async def hitokoto(event: MessageEvent):
async with httpx.AsyncClient() as client:
response = await client.get("https://v.api.aa1.cn/api/api-wenan-wangyiyunreping/index.php?aa1=text")
if response.is_error:
logger.error("获取网抑云失败")
return
# 提取 JSON 部分
pattern = r'<p>(.*?)</p>'
match = re.search(pattern, response.text)
if match:
data = match.group(1)
logger.info(f"解析后的数据:{data}")
mes = (MessageSegment.reply(event.message_id), data.split("——")[0])
await hitokoto_matcher.finish(mes)
else:
logger.warning("未找到 匹配 部分")
_config.register_config()
@@ -0,0 +1,30 @@
"""网抑云 —— 配置注册(按《插件配置文件标准》)。
把接口地址暴露给 Web 可读可改(来源无关,store=本模块)。
"""
from __future__ import annotations
import sys as _sys
from hexi.config_standard import register_config_items
_PLUGIN_ID = __package__
APP_NAME = "网抑云"
API_URL = "https://v.api.aa1.cn/api/api-wenan-wangyiyunreping/index.php?aa1=text"
def register_config() -> None:
register_config_items(
_PLUGIN_ID,
[
{
"key": "API_URL",
"label": "网抑云 API 地址",
"type": "string",
"default": API_URL,
},
],
store=_sys.modules[__name__],
)
@@ -0,0 +1,3 @@
"""网抑云 —— Trigger 层。"""
from .saying import hitokoto_matcher # noqa: F401
@@ -0,0 +1,32 @@
"""网抑云 —— 触发器(Trigger)层。"""
from __future__ import annotations
from nonebot import logger, on_command
from nonebot.adapters.onebot.v11 import MessageEvent, MessageSegment
from ..services.saying import fetch_hitokoto
__help_version__ = "0.1.0"
__help_plugin_name__ = "网抑云"
__usage__ = """一开口就老网抑云了
指令:/网抑云|网易云热评:随机一条网易云热评"""
hitokoto_matcher = on_command("网抑云", aliases={"网易云热评", "emo"})
@hitokoto_matcher.handle()
async def hitokoto(event: MessageEvent):
try:
data = await fetch_hitokoto()
except Exception as e: # noqa: BLE001
logger.error(f"网抑云:获取失败: {e}")
await hitokoto_matcher.finish("获取网抑云失败,请稍后再试")
return
if data is None:
await hitokoto_matcher.finish("获取网抑云失败,请稍后再试")
return
logger.info(f"解析后的数据:{data}")
mes = (MessageSegment.reply(event.message_id), data.split("——")[0])
await hitokoto_matcher.finish(mes)
@@ -0,0 +1,3 @@
"""网抑云 —— Service 层。"""
from .saying import fetch_hitokoto # noqa: F401
@@ -0,0 +1,28 @@
"""网抑云 —— 业务逻辑(Service 层)。"""
from __future__ import annotations
import re
import httpx
from .. import config as _cfg
async def fetch_hitokoto() -> str | None:
"""带超时与重试地拉取网抑云热评文本;多次失败后抛出最后一次异常。"""
last_err: Exception | None = None
for _ in range(3):
try:
async with httpx.AsyncClient(timeout=10.0) as client:
response = await client.get(_cfg.API_URL)
response.raise_for_status()
match = re.search(r"<p>(.*?)</p>", response.text)
if match:
return match.group(1)
return None
except Exception as e: # noqa: BLE001
last_err = e
if last_err:
raise last_err
return None