1
0
forked from bot/app

feat: 状态卡片模糊半径更改

This commit is contained in:
远野千束 2024-04-11 13:15:29 +08:00
parent 79451ac24f
commit d37442bc9d
9 changed files with 151 additions and 95 deletions

View File

@ -33,7 +33,7 @@ protocol_names = {
async def _(bot: T_Bot, event: T_MessageEvent):
ulang = get_user_lang(str(event.user_id))
image = await template2image(
get_path("templates/stats.html", abs_path=True),
get_path("templates/stats.html", abs_path=True, debug=True),
{
"data": await get_stats_data(bot.self_id, ulang.lang_code)
},

View File

@ -1,10 +1,12 @@
# 轻雪资源包管理器
import os
import nonebot
import yaml
from nonebot import require
from nonebot.permission import SUPERUSER
from liteyuki.utils.config import get_config
from liteyuki.utils.language import get_user_lang
from liteyuki.utils.ly_typing import T_Bot, T_MessageEvent
from liteyuki.utils.message import Markdown as md

View File

@ -1,4 +1,6 @@
from nonebot.plugin import PluginMetadata
from .qweather import *
__plugin_meta__ = PluginMetadata(
name="轻雪天气",

View File

@ -1,15 +1,27 @@
import nonebot
from nonebot import require
from liteyuki.utils.config import get_config
from liteyuki.utils.ly_typing import T_Bot
require("nonebot_plugin_alconna")
from nonebot_plugin_alconna import on_alconna, Alconna, Subcommand, Args, MultiVar, Arparma
from nonebot_plugin_alconna import on_alconna, Alconna, Args, Arparma, MultiVar
@on_alconna(
aliases={"天气"},
command=Alconna(
"weather",
Args["keywords", MultiVar(str)],
Args["keywords", MultiVar(str), []],
),
).handle()
async def _(result: Arparma):
"""await alconna.send("weather", city)"""
async def _(bot: T_Bot, result: Arparma):
"""
天气查询
Args:
bot:
Returns:
"""
print("AAA", result, result.main_args)

View File

@ -11,7 +11,92 @@ body {
.info-box {
border-radius: 30px;
padding: 30px;
backdrop-filter: blur(60px);
backdrop-filter: blur(10px);
background-color: rgba(0, 0, 0, 0.3);
margin-bottom: 20px;
}
.pie-chart {
height: 240px;
width: 240px;
margin-bottom: 20px;
}
.pie-info {
margin: 0 40px;
align-items: center;
}
.bot-info {
align-items: center;
display: flex;
}
#hardware-info {
justify-content: center;
text-align: center;
display: flex;
}
#disks-info {
flex-wrap: wrap;
justify-content: center;
}
#motto-info {
margin-bottom: 0;
text-align: center;
white-space: pre-wrap;
}
.bot-icon {
border-radius: 50%;
height: 200px;
background-color: white;
}
.bot-name, .bot-tag {
margin-left: 20px;
}
.bot-name {
font-size: 42px;
font-weight: bold;
}
.bot-tag {
margin-top: 10px;
}
.chart-label {
font-size: 24px;
max-width: 240px;
}
.tag {
font-size: 32px;
font-weight: 700;
font-style: italic;
}
.tag[suffix="1"]::after {
content: " | ";
display: inline-block;
margin: 0 5px;
height: 50%;
line-height: 50%;
color: #ccc;
}
.motto-text {
font-size: 36px;
color: #fff;
}
.motto-author {
font-size: 30px;
font-style: italic;
color: #ccc;
}

View File

@ -123,16 +123,30 @@
mottoAuthor.style.textAlign = 'right';
mottoDiv.appendChild(mottoAuthor);
function getPieUsage(data){
let total = 0
let used = 0
data.forEach(item => {
total += item.value
if(item.name === 'FREE'){
used += item.value
}
})
console.log(used, total)
return used / total * 100
}
function getPieOption(title, data) {
return {
animation: false,
title: {
text: title,
text: title + '\n' + getPieUsage(data).toFixed(1) + '%',
left: 'center',
top: 'center',
textStyle: {
//文字颜色
lineHeight: 36,
color: '#fff',
fontSize: 30
}

View File

@ -7,93 +7,6 @@
<title>Liteyuki Stats</title>
<link rel="stylesheet" href="css/fonts.css">
<link rel="stylesheet" href="css/style.css">
<style>
.pie-chart {
height: 240px;
width: 240px;
margin-bottom: 20px;
}
.pie-info {
margin: 0 40px;
align-items: center;
}
.bot-info {
align-items: center;
display: flex;
}
#hardware-info {
justify-content: center;
text-align: center;
display: flex;
}
#disks-info {
flex-wrap: wrap;
justify-content: center;
}
#motto-info {
margin-bottom: 0;
text-align: center;
white-space: pre-wrap;
}
.bot-icon {
border-radius: 50%;
height: 200px;
background-color: white;
}
.bot-name, .bot-tag {
margin-left: 20px;
}
.bot-name {
font-size: 42px;
font-weight: bold;
}
.bot-tag {
margin-top: 10px;
}
.chart-label {
font-size: 24px;
max-width: 240px;
}
.tag {
font-size: 32px;
font-weight: 700;
font-style: italic;
}
.tag[suffix="1"]::after {
content: " | ";
display: inline-block;
margin: 0 5px;
height: 50%;
line-height: 50%;
color: #ccc;
}
.motto-text {
font-size: 36px;
color: #fff;
}
.motto-author {
font-size: 30px;
font-style: italic;
color: #ccc;
}
</style>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/echarts/4.3.0/echarts.min.js"></script>
</head>

View File

@ -4,6 +4,8 @@ import nonebot
import yaml
from pydantic import BaseModel
from liteyuki.utils.data_manager import StoredConfig, common_db
from liteyuki.utils.ly_typing import T_Bot
from liteyuki.utils.tools import random_hex_string
config = {} # 全局配置,确保加载后读取
@ -34,6 +36,28 @@ def load_from_yaml(file: str) -> dict:
return conf
def get_config(key: str, bot: T_Bot = None, default=None):
"""获取配置项优先级bot > config > db > yaml"""
if bot is None:
bot_config = {}
else:
bot_config = bot.config.dict()
if key in bot_config:
return bot_config[key]
elif key in config:
return config[key]
elif key in common_db.first(StoredConfig(), default=StoredConfig()).config:
return common_db.first(StoredConfig(), default=StoredConfig()).config[key]
elif key in load_from_yaml("config.yml"):
return load_from_yaml("config.yml")[key]
else:
return default
def init_conf(conf: dict) -> dict:
if "" not in conf.get("command_start", []):
conf["alconna_use_command_start"] = True

View File

@ -47,15 +47,19 @@ def load_resource_from_dir(path: str):
_loaded_resource_packs.insert(0, ResourceMetadata(**metadata))
def get_path(path: str, abs_path: bool = False, default: Any = None) -> str | Any:
def get_path(path: str, abs_path: bool = False, default: Any = None, debug: bool=False) -> str | Any:
"""
获取资源包中的文件
Args:
debug: 启用调试每次都会先重载资源
abs_path: 是否返回绝对路径
default: 默认
path: 文件相对路径
Returns: 文件绝对路径
"""
if debug:
nonebot.logger.debug("Enable resource debug, Reloading resources")
load_resources()
resource_relative_path = os.path.join(temp_resource_root, path)
if os.path.exists(resource_relative_path):
return os.path.abspath(resource_relative_path) if abs_path else resource_relative_path