😴提高汉化精准度,强调版权声明

This commit is contained in:
EillesWan 2024-07-26 01:23:01 +08:00
parent da08f8d085
commit 3ede8f710d
23 changed files with 657 additions and 183 deletions

View File

@ -29,6 +29,7 @@
- 感谢[NoneBot2](https://nonebot.dev)提供的框架支持 - 感谢[NoneBot2](https://nonebot.dev)提供的框架支持
- 感谢[nonebot-plugin-htmlrender](https://github.com/kexue-z/nonebot-plugin-htmlrender)提供的渲染功能 - 感谢[nonebot-plugin-htmlrender](https://github.com/kexue-z/nonebot-plugin-htmlrender)提供的渲染功能
- 讨厌上述项目提供的**基于 Chromium 浏览器**的 HTML 渲染功能,就功能本身而言很好,但我讨厌一声不响在我电脑里装浏览器这个行为,虽然这并不妨碍我感谢之 ——金羿
- 感谢[nonebot-plugin-alconna](https://github.com/ArcletProject/nonebot-plugin-alconna)提供的命令解析功能 - 感谢[nonebot-plugin-alconna](https://github.com/ArcletProject/nonebot-plugin-alconna)提供的命令解析功能
- 十分感谢[神羽 SnowyKami](https://github.com/snowykami)提供的技术指导和服务器资源 - 十分感谢[神羽 SnowyKami](https://github.com/snowykami)提供的技术指导和服务器资源
- 特别感谢[云裳工作室](https://doc.ysmcc.cn/doc/1/)提供的服务器挂载 - 特别感谢[云裳工作室](https://doc.ysmcc.cn/doc/1/)提供的服务器挂载
@ -39,8 +40,8 @@
本特定版本的 轻雪机器人 以 汉玉律许可协议 授权开源\ 本特定版本的 轻雪机器人 以 汉玉律许可协议 授权开源\
兼容并继承自 LSO license (LiteyukiStudio Opensource license) 兼容并继承自 LSO license (LiteyukiStudio Opensource license)
版权所有 © 2024 SnowyKami & EillesWan 版权所有 © 2024 神羽 SnowyKami & 金羿 Eilles\
保留所有权利
轻雪机器人睿乐定制版(LiteyukiBot-TriMO)根据 第一版 汉钰律许可协议(“本协议”)授权。\ 轻雪机器人睿乐定制版(LiteyukiBot-TriMO)根据 第一版 汉钰律许可协议(“本协议”)授权。\
任何人皆可从以下地址获得本协议副本:[汉钰律许可协议 第一版](https://gitee.com/EillesWan/YulvLicenses/raw/master/%E6%B1%89%E9%92%B0%E5%BE%8B%E8%AE%B8%E5%8F%AF%E5%8D%8F%E8%AE%AE/%E6%B1%89%E9%92%B0%E5%BE%8B%E8%AE%B8%E5%8F%AF%E5%8D%8F%E8%AE%AE.MD)。\ 任何人皆可从以下地址获得本协议副本:[汉钰律许可协议 第一版](https://gitee.com/EillesWan/YulvLicenses/raw/master/%E6%B1%89%E9%92%B0%E5%BE%8B%E8%AE%B8%E5%8F%AF%E5%8D%8F%E8%AE%AE/%E6%B1%89%E9%92%B0%E5%BE%8B%E8%AE%B8%E5%8F%AF%E5%8D%8F%E8%AE%AE.MD)。\

View File

@ -34,20 +34,6 @@ class LiteyukiBot:
self.lifespan: Lifespan = Lifespan() self.lifespan: Lifespan = Lifespan()
self.init(**self.config) # 初始化 self.init(**self.config) # 初始化
print("\033[34m" + r"""
""" + "\033[0m")
def run(self, *args, **kwargs): def run(self, *args, **kwargs):
if _MAIN_PROCESS: if _MAIN_PROCESS:

View File

@ -1,6 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved Copyright (C) 2020-2024 LiteyukiStudio. All rights reserved
版权所有 © 2020-2024 神羽SnowyKami & 金羿Eilles with LiteyukiStudio & TriM Org.
保留所有权利
@Time : 2024/7/23 下午8:24 @Time : 2024/7/23 下午8:24
@Author : snowykami @Author : snowykami

View File

@ -1,6 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved Copyright (C) 2020-2024 LiteyukiStudio. All rights reserved
版权所有 © 2020-2024 神羽SnowyKami & 金羿Eilles with LiteyukiStudio & TriM Org.
保留所有权利
@Time : 2024/7/23 下午11:59 @Time : 2024/7/23 下午11:59
@Author : snowykami @Author : snowykami

View File

@ -1,6 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved Copyright (C) 2020-2024 LiteyukiStudio. All rights reserved
版权所有 © 2020-2024 神羽SnowyKami & 金羿Eilles with LiteyukiStudio & TriM Org.
保留所有权利
@Time : 2024/7/23 下午11:59 @Time : 2024/7/23 下午11:59
@Author : snowykami @Author : snowykami

View File

@ -1,6 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved Copyright (C) 2020-2024 LiteyukiStudio. All rights reserved
版权所有 © 2020-2024 神羽SnowyKami & 金羿Eilles with LiteyukiStudio & TriM Org.
保留所有权利
@Time : 2024/7/24 上午12:02 @Time : 2024/7/24 上午12:02
@Author : snowykami @Author : snowykami

View File

@ -1,6 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved Copyright (C) 2020-2024 LiteyukiStudio. All rights reserved
版权所有 © 2020-2024 神羽SnowyKami & 金羿Eilles with LiteyukiStudio & TriM Org.
保留所有权利
@Time : 2024/7/23 下午11:21 @Time : 2024/7/23 下午11:21
@Author : snowykami @Author : snowykami

View File

@ -18,6 +18,28 @@ __plugin_meta__ = PluginMetadata(
from ..utils.base.language import Language, get_default_lang_code from ..utils.base.language import Language, get_default_lang_code
print(
"\033[34m"
+ r"""
商标标记 © 2024 金羿Eilles
版权所有 © 2020-2024 神羽SnowyKami & 金羿Eilles\\
with LiteyukiStudio & TriM Org.
保留所有权利
"""
+ "\033[0m"
)
sys_lang = Language(get_default_lang_code()) sys_lang = Language(get_default_lang_code())
nonebot.logger.info( nonebot.logger.info(

View File

@ -17,11 +17,7 @@ async def count_msg_by_bot_id(bot_id: str) -> int:
condition = " AND bot_id = ?" condition = " AND bot_id = ?"
condition_args = [bot_id] condition_args = [bot_id]
msg_rows = msg_db.where_all( msg_rows = msg_db.where_all(MessageEventModel(), condition, *condition_args)
MessageEventModel(),
condition,
*condition_args
)
return len(msg_rows) return len(msg_rows)
@ -32,7 +28,7 @@ async def get_stat_msg_image(
group_id: str = None, group_id: str = None,
bot_id: str = None, bot_id: str = None,
user_id: str = None, user_id: str = None,
ulang: Language = Language() ulang: Language = Language(),
) -> bytes: ) -> bytes:
""" """
获取统计消息 获取统计消息
@ -48,7 +44,7 @@ async def get_stat_msg_image(
tuple: [int,], [int,] 两个列表分别为周期中心时间戳和消息数量 tuple: [int,], [int,] 两个列表分别为周期中心时间戳和消息数量
""" """
now = int(time.time()) now = int(time.time())
start_time = (now - duration) start_time = now - duration
condition = "time > ?" condition = "time > ?"
condition_args = [start_time] condition_args = [start_time]
@ -64,11 +60,7 @@ async def get_stat_msg_image(
condition += " AND user_id = ?" condition += " AND user_id = ?"
condition_args.append(user_id) condition_args.append(user_id)
msg_rows = msg_db.where_all( msg_rows = msg_db.where_all(MessageEventModel(), condition, *condition_args)
MessageEventModel(),
condition,
*condition_args
)
timestamps = [] timestamps = []
msg_count = [] msg_count = []
msg_rows.sort(key=lambda x: x.time) msg_rows.sort(key=lambda x: x.time)
@ -88,12 +80,16 @@ async def get_stat_msg_image(
templates = { templates = {
"data": [ "data": [
{ {
"name" : ulang.get("stat.message") "name": "{}为分割,在{}范围内的 {}".format(
+ f" Period {convert_seconds_to_time(period)}" + f" Duration {convert_seconds_to_time(duration)}" convert_seconds_to_time(period),
+ (f" Group {group_id}" if group_id else "") + (f" Bot {bot_id}" if bot_id else "") + ( convert_seconds_to_time(duration),
f" User {user_id}" if user_id else ""), ulang.get("stat.message"),
)
+ (f" 群聊:{group_id}" if group_id else "")
+ (f" 机器:{bot_id}" if bot_id else "")
+ (f" 用户:{user_id}" if user_id else ""),
"times": timestamps, "times": timestamps,
"counts": msg_count "counts": msg_count,
} }
] ]
} }
@ -129,11 +125,7 @@ async def get_stat_rank_image(
condition += " AND time > ?" condition += " AND time > ?"
condition_args.append(v) condition_args.append(v)
msg_rows = msg_db.where_all( msg_rows = msg_db.where_all(MessageEventModel(), condition, *condition_args)
MessageEventModel(),
condition,
*condition_args
)
""" """
{ {
@ -153,20 +145,24 @@ async def get_stat_rank_image(
{ {
"name": _[0], "name": _[0],
"count": _[1], "count": _[1],
"icon" : await (get_group_icon(platform="qq", group_id=_[0]) if rank_type == "group" else get_user_icon( "icon": await (
platform="qq", user_id=_[0] get_group_icon(platform="qq", group_id=_[0])
)) if rank_type == "group"
else get_user_icon(platform="qq", user_id=_[0])
),
} }
for _ in sorted_data[0 : min(len(sorted_data), limit["rank"])] for _ in sorted_data[0 : min(len(sorted_data), limit["rank"])]
] ]
templates = { templates = {
"data": "data": {
{ "name": ulang.get("stat.rank")
"name" : ulang.get("stat.rank") + f" Type {rank_type}" + f" Limit {limit}", + f" 类别:{rank_type}"
"ranking": ranking + f" 制约:{limit}",
"ranking": ranking,
}
} }
} return await template2image(
get_path("templates/stat_rank.html"), templates, debug=True
return await template2image(get_path("templates/stat_rank.html"), templates, debug=True) )

View File

@ -15,7 +15,7 @@ from nonebot_plugin_alconna import (
Subcommand, Subcommand,
Arparma, Arparma,
Option, Option,
MultiVar MultiVar,
) )
stat_msg = on_alconna( stat_msg = on_alconna(
@ -40,17 +40,11 @@ stat_msg = on_alconna(
help_text="是否指定机器人", help_text="是否指定机器人",
), ),
Option( Option(
"-g|--group", "-g|--group", Args["group_id", str, "current"], help_text="指定群组"
Args["group_id", str, "current"],
help_text="指定群组"
),
Option(
"-u|--user",
Args["user_id", str, "current"],
help_text="指定用户"
), ),
Option("-u|--user", Args["user_id", str, "current"], help_text="指定用户"),
alias={"msg", "m"}, alias={"msg", "m"},
help_text="查看统计次数内的消息" help_text="查看统计次数内的消息",
), ),
Subcommand( Subcommand(
"rank", "rank",
@ -78,9 +72,9 @@ stat_msg = on_alconna(
help_text="指定排名", help_text="指定排名",
), ),
alias={"r"}, alias={"r"},
)
), ),
aliases={"stat"} ),
aliases={"stat"},
) )
@ -88,10 +82,14 @@ stat_msg = on_alconna(
async def _(result: Arparma, event: T_MessageEvent, bot: Bot): async def _(result: Arparma, event: T_MessageEvent, bot: Bot):
ulang = Language(event_utils.get_user_id(event)) ulang = Language(event_utils.get_user_id(event))
try: try:
duration = convert_time_to_seconds(result.other_args.get("duration", "2d")) # 秒数 duration = convert_time_to_seconds(
result.other_args.get("duration", "2d")
) # 秒数
period = convert_time_to_seconds(result.other_args.get("period", "1m")) period = convert_time_to_seconds(result.other_args.get("period", "1m"))
except BaseException as e: except BaseException as e:
await stat_msg.send(ulang.get("liteyuki.invalid_command", TEXT=str(e.__str__()))) await stat_msg.send(
ulang.get("liteyuki.invalid_command", TEXT=str(e.__str__()))
)
return return
group_id = result.other_args.get("group_id") group_id = result.other_args.get("group_id")
@ -110,7 +108,14 @@ async def _(result: Arparma, event: T_MessageEvent, bot: Bot):
if user_id in ["current", "c"]: if user_id in ["current", "c"]:
user_id = str(event_utils.get_user_id(event)) user_id = str(event_utils.get_user_id(event))
img = await get_stat_msg_image(duration=duration, period=period, group_id=group_id, bot_id=bot_id, user_id=user_id, ulang=ulang) img = await get_stat_msg_image(
duration=duration,
period=period,
group_id=group_id,
bot_id=bot_id,
user_id=user_id,
ulang=ulang,
)
await stat_msg.send(UniMessage.image(raw=img)) await stat_msg.send(UniMessage.image(raw=img))

View File

@ -1,7 +1,7 @@
from nonebot.plugin import PluginMetadata from nonebot.plugin import PluginMetadata
from .status import * from .status import *
__author__ = "snowykami & 金羿Eilles" __author__ = "神羽SnowyKami & 金羿Eilles"
__plugin_meta__ = PluginMetadata( __plugin_meta__ = PluginMetadata(
name="状态查看器", name="状态查看器",
description="", description="",

View File

@ -23,12 +23,12 @@ from git import Repo
commit_hash = Repo(".").head.commit.hexsha commit_hash = Repo(".").head.commit.hexsha
protocol_names = { protocol_names = {
0: "iPad", 0: "苹果iPad",
1: "Android Phone", 1: "安卓掌机",
2: "Android Watch", 2: "安卓穿戴",
3: "Mac", 3: "Mac主机",
5: "iPad", 5: "苹果iPad",
6: "Android Pad", 6: "安卓平板",
} }
""" """
@ -175,7 +175,7 @@ async def get_bots_data(self_id: str = "0") -> dict:
pass pass
statistics = status.get("stat", {}) statistics = status.get("stat", {})
app_name = version_info.get("app_name", "UnknownImplementation") app_name = version_info.get("app_name", "未知应用接口")
if app_name in ["Lagrange.OneBot", "LLOneBot", "Shamrock", "NapCat.Onebot"]: if app_name in ["Lagrange.OneBot", "LLOneBot", "Shamrock", "NapCat.Onebot"]:
icon = f"https://q.qlogo.cn/g?b=qq&nk={bot_id}&s=640" icon = f"https://q.qlogo.cn/g?b=qq&nk={bot_id}&s=640"
elif isinstance(bot, satori.Bot): elif isinstance(bot, satori.Bot):
@ -188,7 +188,7 @@ async def get_bots_data(self_id: str = "0") -> dict:
"icon": icon, "icon": icon,
"id": bot_id, "id": bot_id,
"protocol_name": protocol_names.get( "protocol_name": protocol_names.get(
version_info.get("protocol_name"), "Online" version_info.get("protocol_name"), "在线"
), ),
"groups": groups, "groups": groups,
"friends": friends, "friends": friends,
@ -226,17 +226,19 @@ async def get_hardware_data() -> dict:
except Exception: except Exception:
pass pass
swap = psutil.swap_memory() swap = psutil.swap_memory()
cpu_brand_raw = cpuinfo.get_cpu_info().get("brand_raw", "Unknown") cpu_brand_raw = cpuinfo.get_cpu_info().get("brand_raw", "未知处理器")
if "AMD" in cpu_brand_raw: if "AMD" in cpu_brand_raw:
brand = "AMD" brand = "AMD"
elif "Intel" in cpu_brand_raw: elif "Intel" in cpu_brand_raw:
brand = "Intel" brand = "英特尔"
elif "Nvidia" in cpu_brand_raw:
brand = "英伟达"
else: else:
brand = "Unknown" brand = "未知处理器"
result = { result = {
"cpu": { "cpu": {
"percent": psutil.cpu_percent(), "percent": psutil.cpu_percent(),
"name": f"{brand} {cpuinfo.get_cpu_info().get('arch', 'Unknown')}", "name": f"{brand} {cpuinfo.get_cpu_info().get('arch', '未知架构')}",
"cores": psutil.cpu_count(logical=False), "cores": psutil.cpu_count(logical=False),
"threads": psutil.cpu_count(logical=True), "threads": psutil.cpu_count(logical=True),
"freq": psutil.cpu_freq().current, # MHz "freq": psutil.cpu_freq().current, # MHz

View File

@ -137,7 +137,7 @@ async def _(
or ulang.lang_code not in status_card_cache.keys() or ulang.lang_code not in status_card_cache.keys()
or ( or (
ulang.lang_code in status_card_cache.keys() ulang.lang_code in status_card_cache.keys()
and time.time() - status_card_cache[ulang.lang_code][1] > 60 and time.time() - status_card_cache[ulang.lang_code][1] > 300 # 缓存
) )
): ):
status_card_cache[ulang.lang_code] = ( status_card_cache[ulang.lang_code] = (

View File

@ -44,8 +44,8 @@ data.forEach((item) => {
function timestampToTime(timestamp) { function timestampToTime(timestamp) {
let date = new Date(timestamp * 1000) let date = new Date(timestamp * 1000)
let Y = date.getFullYear() + '-' let Y = date.getFullYear() + '/'
let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-' let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '/'
let D = date.getDate() + ' ' let D = date.getDate() + ' '
let h = date.getHours() + ':' let h = date.getHours() + ':'
let m = date.getMinutes() + ':' let m = date.getMinutes() + ':'

View File

@ -3,12 +3,12 @@ let data = JSON.parse(document.getElementById("data").innerText) // object
const rowDiv = document.importNode(document.getElementById("row-template").content, true) const rowDiv = document.importNode(document.getElementById("row-template").content, true)
function randomHideChar(str) { function randomHideChar(str) {
// 随机隐藏6位以上字符串的中间连续四位字符,用*代替 // 随机隐藏6位以上字符串的中间连续5位字符代替
if (str.length <= 6) { if (str.length <= 6) {
return str return str
} }
let start = Math.floor(str.length / 2) - 2 let start = Math.floor(str.length / 2) - 2
return str.slice(0, start) + "****" + str.slice(start + 4) return str.slice(0, start) + "(¬‿¬)" + str.slice(start + 5)
} }
data["ranking"].forEach((item) => { data["ranking"].forEach((item) => {
let row = rowDiv.cloneNode(true) let row = rowDiv.cloneNode(true)

View File

@ -19,7 +19,8 @@
<div class="data-storage" id="data">{{ data | tojson }}</div> <div class="data-storage" id="data">{{ data | tojson }}</div>
<div class="info-box" id="addition-info"></div> <div class="info-box" id="addition-info"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.5.0/echarts.min.js"></script> <script
src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.5.0/echarts.min.js"></script>
<script src="./js/stat_msg.js"></script> <script src="./js/stat_msg.js"></script>
<script src="./js/card.js"></script> <script src="./js/card.js"></script>
</body> </body>

View File

@ -51,7 +51,8 @@
<div class="data-storage" id="data">{{ data | tojson }}</div> <div class="data-storage" id="data">{{ data | tojson }}</div>
<div class="info-box" id="addition-info"></div> <div class="info-box" id="addition-info"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.5.0/echarts.min.js"></script> <script
src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.5.0/echarts.min.js"></script>
<script src="./js/stat_rank.js"></script> <script src="./js/stat_rank.js"></script>
<script src="./js/card.js"></script> <script src="./js/card.js"></script>
</body> </body>

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

View File

@ -153,7 +153,7 @@ function main() {
// 添加轻雪信息 // 添加轻雪信息
let liteyukiInfoDiv = document.importNode(document.getElementById('bot-template').content, true) // 复制模板 let liteyukiInfoDiv = document.importNode(document.getElementById('bot-template').content, true) // 复制模板
liteyukiInfoDiv.className = 'info-box bot-info' liteyukiInfoDiv.className = 'info-box bot-info'
liteyukiInfoDiv.querySelector('.bot-icon-img').setAttribute('src', './img/liteyuki.png') liteyukiInfoDiv.querySelector('.bot-icon-img').setAttribute('src', './img/litetrimo.png')
liteyukiInfoDiv.querySelector('.bot-name').innerText = `${liteyukiData['name']} - 睿乐` liteyukiInfoDiv.querySelector('.bot-name').innerText = `${liteyukiData['name']} - 睿乐`
let tagArray = [ let tagArray = [
@ -186,7 +186,7 @@ function main() {
const cpuTagArray = [ const cpuTagArray = [
cpuData['name'], cpuData['name'],
`${cpuData['cores']}${localData['cores']} ${cpuData['threads']}${localData['threads']}`, `${cpuData['cores']}${localData['cores']} ${cpuData['threads']}${localData['threads']}`,
`${(cpuData['freq'] / 1000).toFixed(2)}GHz` `${(cpuData['freq'] / 1000).toFixed(2)}吉赫兹`
] ]
const memTagArray = [ const memTagArray = [

View File

@ -7,13 +7,13 @@
<title>Liteyuki Stats</title> <title>Liteyuki Stats</title>
<link rel="stylesheet" href="css/fonts.css"> <link rel="stylesheet" href="css/fonts.css">
<link rel="stylesheet" href="css/style.css"> <link rel="stylesheet" href="css/style.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/echarts/4.3.0/echarts.min.js"></script> <script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/echarts/4.3.0/echarts.min.js"></script>
</head> </head>
<body> <body>
<div class="info-box" id="hardware-info"> <div class="info-box" id="hardware-info">
<div class="pie-info" id="cpu-info"> <div class="pie-info" id="cpu-info">
<div class="pie-chart" id="cpu-chart"></div> <div class="pie-chart" id="cpu-chart"></div>

View File

@ -8,7 +8,6 @@ import nonebot
__NAME__ = "尹灵温|轻雪-睿乐" __NAME__ = "尹灵温|轻雪-睿乐"
__VERSION__ = "6.3.4" # 60201 __VERSION__ = "6.3.4" # 60201
# __VERSION_I__ = 99060303
import requests import requests