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>
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
import re
|
|
from functools import partial
|
|
from pathlib import Path
|
|
from typing import TYPE_CHECKING
|
|
|
|
from cookit import DebugFileWriter, auto_convert_unit, format_timedelta
|
|
|
|
if TYPE_CHECKING:
|
|
from .services.collectors.cpu import CpuFreq
|
|
|
|
format_time_delta_ps = partial(format_timedelta, day_divider=" ", day_suffix="天")
|
|
|
|
|
|
def match_list_regexp(reg_list: list[str], txt: str) -> re.Match | None:
|
|
return next((match for r in reg_list if (match := re.search(r, txt))), None)
|
|
|
|
|
|
def format_freq(value: float) -> str:
|
|
"""将 MHz 频率格式化为 MHz/GHz(十进制 1000 换算)"""
|
|
return auto_convert_unit(
|
|
units=("MHz", "GHz", "THz"),
|
|
multiplier=1000,
|
|
unit_threshold=1000,
|
|
value=value,
|
|
with_space=False,
|
|
)
|
|
|
|
|
|
def format_cpu_freq(freq: "CpuFreq") -> str:
|
|
if not freq.current and not freq.max:
|
|
return "主频未知"
|
|
current = freq.current or freq.max or 0.0
|
|
max_freq = freq.max or 0.0
|
|
if not max_freq or max_freq == current:
|
|
return format_freq(current)
|
|
return f"{format_freq(current)} / {format_freq(max_freq)}"
|
|
|
|
|
|
debug = DebugFileWriter(Path(__file__).resolve().parents[2] / "logs", "picstatus")
|