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

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,18 +29,19 @@
- 感谢[NoneBot2](https://nonebot.dev)提供的框架支持
- 感谢[nonebot-plugin-htmlrender](https://github.com/kexue-z/nonebot-plugin-htmlrender)提供的渲染功能
- 讨厌上述项目提供的**基于 Chromium 浏览器**的 HTML 渲染功能,就功能本身而言很好,但我讨厌一声不响在我电脑里装浏览器这个行为,虽然这并不妨碍我感谢之 ——金羿
- 感谢[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/)提供的服务器挂载
- 由衷感谢我在学习生活中遇到的所有朋友们,你们身为我生命中的一处景色,不断地推进我此生的进程。
### 许可证
本特定版本的 轻雪机器人 以 汉玉律许可协议 授权开源\
兼容并继承自LSO license (LiteyukiStudio Opensource license)
版权所有 © 2024 SnowyKami & EillesWan
兼容并继承自 LSO license (LiteyukiStudio Opensource license)
版权所有 © 2024 神羽 SnowyKami & 金羿 Eilles\
保留所有权利
轻雪机器人睿乐定制版(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)。\

View File

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

View File

@ -1,6 +1,9 @@
# -*- 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
@Author : snowykami

View File

@ -1,6 +1,9 @@
# -*- 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
@Author : snowykami

View File

@ -1,6 +1,9 @@
# -*- 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
@Author : snowykami

View File

@ -1,6 +1,9 @@
# -*- 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
@Author : snowykami

View File

@ -1,6 +1,9 @@
# -*- 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
@Author : snowykami

View File

@ -18,6 +18,28 @@ __plugin_meta__ = PluginMetadata(
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())
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_args = [bot_id]
msg_rows = msg_db.where_all(
MessageEventModel(),
condition,
*condition_args
)
msg_rows = msg_db.where_all(MessageEventModel(), condition, *condition_args)
return len(msg_rows)
@ -32,7 +28,7 @@ async def get_stat_msg_image(
group_id: str = None,
bot_id: str = None,
user_id: str = None,
ulang: Language = Language()
ulang: Language = Language(),
) -> bytes:
"""
获取统计消息
@ -48,7 +44,7 @@ async def get_stat_msg_image(
tuple: [int,], [int,] 两个列表分别为周期中心时间戳和消息数量
"""
now = int(time.time())
start_time = (now - duration)
start_time = now - duration
condition = "time > ?"
condition_args = [start_time]
@ -64,11 +60,7 @@ async def get_stat_msg_image(
condition += " AND user_id = ?"
condition_args.append(user_id)
msg_rows = msg_db.where_all(
MessageEventModel(),
condition,
*condition_args
)
msg_rows = msg_db.where_all(MessageEventModel(), condition, *condition_args)
timestamps = []
msg_count = []
msg_rows.sort(key=lambda x: x.time)
@ -88,12 +80,16 @@ async def get_stat_msg_image(
templates = {
"data": [
{
"name" : ulang.get("stat.message")
+ f" Period {convert_seconds_to_time(period)}" + f" Duration {convert_seconds_to_time(duration)}"
+ (f" Group {group_id}" if group_id else "") + (f" Bot {bot_id}" if bot_id else "") + (
f" User {user_id}" if user_id else ""),
"times" : timestamps,
"counts": msg_count
"name": "{}为分割,在{}范围内的 {}".format(
convert_seconds_to_time(period),
convert_seconds_to_time(duration),
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,
"counts": msg_count,
}
]
}
@ -129,11 +125,7 @@ async def get_stat_rank_image(
condition += " AND time > ?"
condition_args.append(v)
msg_rows = msg_db.where_all(
MessageEventModel(),
condition,
*condition_args
)
msg_rows = msg_db.where_all(MessageEventModel(), condition, *condition_args)
"""
{
@ -151,22 +143,26 @@ async def get_stat_rank_image(
ranking: list[dict[str, Any]] = [
{
"name" : _[0],
"name": _[0],
"count": _[1],
"icon" : await (get_group_icon(platform="qq", group_id=_[0]) if rank_type == "group" else get_user_icon(
platform="qq", user_id=_[0]
))
"icon": await (
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 = {
"data":
{
"name" : ulang.get("stat.rank") + f" Type {rank_type}" + f" Limit {limit}",
"ranking": ranking
"data": {
"name": ulang.get("stat.rank")
+ f" 类别:{rank_type}"
+ 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,
Arparma,
Option,
MultiVar
MultiVar,
)
stat_msg = on_alconna(
@ -40,17 +40,11 @@ stat_msg = on_alconna(
help_text="是否指定机器人",
),
Option(
"-g|--group",
Args["group_id", str, "current"],
help_text="指定群组"
),
Option(
"-u|--user",
Args["user_id", str, "current"],
help_text="指定用户"
"-g|--group", Args["group_id", str, "current"], help_text="指定群组"
),
Option("-u|--user", Args["user_id", str, "current"], help_text="指定用户"),
alias={"msg", "m"},
help_text="查看统计次数内的消息"
help_text="查看统计次数内的消息",
),
Subcommand(
"rank",
@ -78,9 +72,9 @@ stat_msg = on_alconna(
help_text="指定排名",
),
alias={"r"},
)
),
aliases={"stat"}
),
aliases={"stat"},
)
@ -88,10 +82,14 @@ stat_msg = on_alconna(
async def _(result: Arparma, event: T_MessageEvent, bot: Bot):
ulang = Language(event_utils.get_user_id(event))
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"))
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
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"]:
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))

View File

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

View File

@ -23,12 +23,12 @@ from git import Repo
commit_hash = Repo(".").head.commit.hexsha
protocol_names = {
0: "iPad",
1: "Android Phone",
2: "Android Watch",
3: "Mac",
5: "iPad",
6: "Android Pad",
0: "苹果iPad",
1: "安卓掌机",
2: "安卓穿戴",
3: "Mac主机",
5: "苹果iPad",
6: "安卓平板",
}
"""
@ -175,7 +175,7 @@ async def get_bots_data(self_id: str = "0") -> dict:
pass
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"]:
icon = f"https://q.qlogo.cn/g?b=qq&nk={bot_id}&s=640"
elif isinstance(bot, satori.Bot):
@ -188,7 +188,7 @@ async def get_bots_data(self_id: str = "0") -> dict:
"icon": icon,
"id": bot_id,
"protocol_name": protocol_names.get(
version_info.get("protocol_name"), "Online"
version_info.get("protocol_name"), "在线"
),
"groups": groups,
"friends": friends,
@ -226,17 +226,19 @@ async def get_hardware_data() -> dict:
except Exception:
pass
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:
brand = "AMD"
elif "Intel" in cpu_brand_raw:
brand = "Intel"
brand = "英特尔"
elif "Nvidia" in cpu_brand_raw:
brand = "英伟达"
else:
brand = "Unknown"
brand = "未知处理器"
result = {
"cpu": {
"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),
"threads": psutil.cpu_count(logical=True),
"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 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] = (

View File

@ -44,8 +44,8 @@ data.forEach((item) => {
function timestampToTime(timestamp) {
let date = new Date(timestamp * 1000)
let Y = date.getFullYear() + '-'
let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
let Y = date.getFullYear() + '/'
let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '/'
let D = date.getDate() + ' '
let h = date.getHours() + ':'
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)
function randomHideChar(str) {
// 随机隐藏6位以上字符串的中间连续四位字符,用*代替
// 随机隐藏6位以上字符串的中间连续5位字符代替
if (str.length <= 6) {
return str
}
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) => {
let row = rowDiv.cloneNode(true)

View File

@ -1,15 +1,15 @@
<!DOCTYPE html>
<html lang="zh" xmlns="http://www.w3.org/1999/html">
<head>
<head>
<meta charset="UTF-8">
<title>Liteyuki Stats Message</title>
<link rel="stylesheet" href="./css/card.css">
<link rel="stylesheet" href="./css/fonts.css">
<link rel="stylesheet" href="./css/stat_msg.css">
</head>
</head>
<body>
<body>
<template id="sign-chart-template">
<div class="info-box sign-chart">
@ -19,7 +19,8 @@
<div class="data-storage" id="data">{{ data | tojson }}</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/card.js"></script>
</body>
</body>

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="zh" xmlns="http://www.w3.org/1999/html">
<head>
<head>
<meta charset="UTF-8">
<title>Liteyuki Stats Message</title>
<link rel="stylesheet" href="./css/card.css">
@ -36,9 +36,9 @@
margin-left: auto;
}
</style>
</head>
</head>
<body>
<body>
<template id="row-template">
<div class="row">
@ -51,7 +51,8 @@
<div class="data-storage" id="data">{{ data | tojson }}</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/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

@ -141,7 +141,7 @@ function main() {
tagSpan.className = 'bot-tag'
tagSpan.innerText = tag
// 给最后一个标签不添加后缀
tagSpan.setAttribute('suffix', (index === 0)||(tag[0] == '\n') ? '0' : '1')
tagSpan.setAttribute('suffix', (index === 0) || (tag[0] == '\n') ? '0' : '1')
botInfoDiv.querySelector('.bot-tags').appendChild(tagSpan)
}
)
@ -153,7 +153,7 @@ function main() {
// 添加轻雪信息
let liteyukiInfoDiv = document.importNode(document.getElementById('bot-template').content, true) // 复制模板
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']} - 睿乐`
let tagArray = [
@ -172,7 +172,7 @@ function main() {
tagSpan.className = 'bot-tag'
tagSpan.innerText = tag
// 给最后一个标签不添加后缀
tagSpan.setAttribute('suffix', (index === 0)||(tag[0] == '\n') ? '0' : '1')
tagSpan.setAttribute('suffix', (index === 0) || (tag[0] == '\n') ? '0' : '1')
liteyukiInfoDiv.querySelector('.bot-tags').appendChild(tagSpan)
}
)
@ -186,7 +186,7 @@ function main() {
const cpuTagArray = [
cpuData['name'],
`${cpuData['cores']}${localData['cores']} ${cpuData['threads']}${localData['threads']}`,
`${(cpuData['freq'] / 1000).toFixed(2)}GHz`
`${(cpuData['freq'] / 1000).toFixed(2)}吉赫兹`
]
const memTagArray = [

View File

@ -1,18 +1,18 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=1080, initial-scale=1.0">
<title>Liteyuki Stats</title>
<link rel="stylesheet" href="css/fonts.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>
<body>
</head>
<body>
<div class="info-box" id="hardware-info">
<div class="pie-info" id="cpu-info">
@ -37,6 +37,6 @@
<script src="js/bg.js"></script>
<!-- <script src="js/motto.js"></script> -->
<script src="js/style.js"></script>
</body>
</body>
</html>

View File

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