✨ 全新的帮助
,管理帮助
, 可调控暗色或亮色 (#75)
74
gsuid_core/help/draw_core_help.py
Normal file
@ -0,0 +1,74 @@
|
||||
from pathlib import Path
|
||||
from typing import Dict, Literal
|
||||
|
||||
import aiofiles
|
||||
from PIL import Image
|
||||
from msgspec import json as msgjson
|
||||
|
||||
from gsuid_core.help.utils import ICON
|
||||
from gsuid_core.version import __version__
|
||||
from gsuid_core.help.model import PluginHelp
|
||||
from gsuid_core.utils.plugins_config.gs_config import sp_config
|
||||
from gsuid_core.help.draw_new_plugin_help import TEXT_PATH, get_new_help
|
||||
|
||||
MASTER_HELP_DATA = Path(__file__).parent / 'master_help.json'
|
||||
HELP_DATA = Path(__file__).parent / 'help.json'
|
||||
help_mode: Literal['light', 'dark'] = sp_config.get_config('HelpMode').data
|
||||
|
||||
|
||||
async def get_master_help_data() -> Dict[str, PluginHelp]:
|
||||
async with aiofiles.open(MASTER_HELP_DATA, 'rb') as file:
|
||||
return msgjson.decode(await file.read(), type=Dict[str, PluginHelp])
|
||||
|
||||
|
||||
async def get_help_data() -> Dict[str, PluginHelp]:
|
||||
async with aiofiles.open(HELP_DATA, 'rb') as file:
|
||||
return msgjson.decode(await file.read(), type=Dict[str, PluginHelp])
|
||||
|
||||
|
||||
async def draw_master_help():
|
||||
if help_mode == 'light':
|
||||
item_bg = Image.open(TEXT_PATH / f'item_bg_{help_mode}.png')
|
||||
need_cover = True
|
||||
else:
|
||||
item_bg = None
|
||||
need_cover = False
|
||||
|
||||
img = await get_new_help(
|
||||
plugin_name='GsCore管理',
|
||||
plugin_info={f'v{__version__}': ''},
|
||||
plugin_icon=Image.open(ICON),
|
||||
plugin_help=await get_master_help_data(),
|
||||
plugin_prefix='core',
|
||||
item_bg=item_bg,
|
||||
need_cover=need_cover,
|
||||
help_mode=help_mode,
|
||||
)
|
||||
return img
|
||||
|
||||
|
||||
async def draw_core_help():
|
||||
from .utils import plugins_help
|
||||
|
||||
help_data = await get_help_data()
|
||||
help_data.update(plugins_help) # type: ignore
|
||||
|
||||
if help_mode == 'light':
|
||||
item_bg = Image.open(TEXT_PATH / f'item_bg_{help_mode}.png')
|
||||
need_cover = True
|
||||
else:
|
||||
item_bg = None
|
||||
need_cover = False
|
||||
|
||||
img = await get_new_help(
|
||||
plugin_name='GsCore',
|
||||
plugin_info={f'v{__version__}': ''},
|
||||
plugin_icon=Image.open(ICON),
|
||||
plugin_help=help_data,
|
||||
plugin_prefix='',
|
||||
item_bg=item_bg,
|
||||
need_cover=need_cover,
|
||||
help_mode=help_mode,
|
||||
)
|
||||
|
||||
return img
|
@ -1,3 +1,4 @@
|
||||
import re
|
||||
import random
|
||||
from pathlib import Path
|
||||
from copy import deepcopy
|
||||
@ -11,6 +12,7 @@ from gsuid_core.utils.fonts.fonts import core_font
|
||||
from gsuid_core.utils.image.convert import convert_img
|
||||
from gsuid_core.utils.plugins_config.gs_config import pic_gen_config
|
||||
from gsuid_core.utils.image.image_tools import (
|
||||
CustomizeImage,
|
||||
crop_center_img,
|
||||
draw_color_badge,
|
||||
)
|
||||
@ -39,6 +41,24 @@ def find_icon(name: str, icon_path: Path = ICON_PATH):
|
||||
return Image.open(_r)
|
||||
|
||||
|
||||
def calculate_string_length(s: str):
|
||||
total_length = 0
|
||||
result = ''
|
||||
for char in s:
|
||||
result += char
|
||||
if '\u4e00' <= char <= '\u9fff':
|
||||
total_length += 1
|
||||
elif re.match(r'[A-Za-z0-9]', char):
|
||||
total_length += 0.5
|
||||
elif re.match(r'[^\w\s]', char):
|
||||
total_length += 0.3
|
||||
|
||||
if total_length >= 8:
|
||||
return result
|
||||
else:
|
||||
return result
|
||||
|
||||
|
||||
async def get_new_help(
|
||||
plugin_name: str,
|
||||
plugin_info: Dict[str, str],
|
||||
@ -53,6 +73,8 @@ async def get_new_help(
|
||||
item_bg: Optional[Image.Image] = None,
|
||||
icon_path: Path = ICON_PATH,
|
||||
footer: Optional[Image.Image] = None,
|
||||
column: int = 3,
|
||||
need_cover: bool = False,
|
||||
enable_cache: bool = True,
|
||||
):
|
||||
help_path = get_res_path('help') / f'{plugin_name}.jpg'
|
||||
@ -66,11 +88,11 @@ async def get_new_help(
|
||||
return await convert_img(Image.open(help_path))
|
||||
|
||||
if banner_bg is None:
|
||||
banner_bg = Image.open(TEXT_PATH / 'banner_bg.jpg')
|
||||
banner_bg = Image.open(TEXT_PATH / f'banner_bg_{help_mode}.jpg')
|
||||
if help_bg is None:
|
||||
help_bg = Image.open(TEXT_PATH / 'help_bg.jpg')
|
||||
help_bg = Image.open(TEXT_PATH / f'bg_{help_mode}.jpg')
|
||||
if cag_bg is None:
|
||||
cag_bg = Image.open(TEXT_PATH / 'cag_bg.png')
|
||||
cag_bg = Image.open(TEXT_PATH / f'cag_bg_{help_mode}.png')
|
||||
if footer is None:
|
||||
footer = Image.open(TEXT_PATH / f'footer_{help_mode}.png')
|
||||
if item_bg is None:
|
||||
@ -92,17 +114,13 @@ async def get_new_help(
|
||||
plugin_icon = plugin_icon.resize((128, 128))
|
||||
|
||||
# 准备计算整体帮助图大小
|
||||
w, h = 1545, 300 + footer.height
|
||||
w, h = 120 + 475 * column, footer.height
|
||||
|
||||
cag_num = len(plugin_help)
|
||||
h += cag_num * 100
|
||||
for cag in plugin_help:
|
||||
cag_data = plugin_help[cag]['data']
|
||||
sv_num = len(cag_data)
|
||||
h += (((sv_num - 1) // 3) + 1) * 175
|
||||
|
||||
# 基准图
|
||||
img = crop_center_img(help_bg, w, h)
|
||||
h += (((sv_num - 1) // column) + 1) * 175
|
||||
|
||||
# 绘制banner
|
||||
banner_bg.paste(plugin_icon, (89, 88), plugin_icon)
|
||||
@ -143,6 +161,46 @@ async def get_new_help(
|
||||
|
||||
plugin_name_len += badge.width + 10
|
||||
|
||||
bscale = w / banner_bg.size[0]
|
||||
new_banner_h = int(banner_bg.size[1] * bscale)
|
||||
new_cag_h = int(cag_bg.size[1] * bscale)
|
||||
banner_bg = banner_bg.resize((w, new_banner_h))
|
||||
|
||||
h += new_banner_h
|
||||
h += cag_num * new_cag_h
|
||||
|
||||
# 基准图
|
||||
img = crop_center_img(help_bg, w, h)
|
||||
if need_cover:
|
||||
color = CustomizeImage.get_bg_color(
|
||||
img, False if help_mode == 'dark' else True
|
||||
)
|
||||
if help_mode == 'light':
|
||||
add_color = 40
|
||||
max_color = 255
|
||||
c0 = color[0] + add_color
|
||||
c0 = c0 if c0 < max_color else max_color
|
||||
c1 = color[1] + add_color
|
||||
c2 = color[2] + add_color
|
||||
c1 = c1 if c1 < max_color else max_color
|
||||
c2 = c2 if c2 < max_color else max_color
|
||||
else:
|
||||
add_color = -40
|
||||
max_color = 0
|
||||
c0 = color[0] + add_color
|
||||
c0 = c0 if c0 > max_color else max_color
|
||||
c1 = color[1] + add_color
|
||||
c2 = color[2] + add_color
|
||||
c1 = c1 if c1 > max_color else max_color
|
||||
c2 = c2 if c2 > max_color else max_color
|
||||
_color = (c0, c1, c2, 190)
|
||||
_color_img = Image.new(
|
||||
'RGBA',
|
||||
(w, h),
|
||||
_color,
|
||||
)
|
||||
img.paste(_color_img, (0, 0), _color_img)
|
||||
|
||||
img.paste(banner_bg, (0, 0), banner_bg)
|
||||
|
||||
# 开始粘贴服务
|
||||
@ -171,7 +229,14 @@ async def get_new_help(
|
||||
font=core_font(30),
|
||||
anchor='lm',
|
||||
)
|
||||
img.paste(cag_bar, (0, 280 + hs), cag_bar)
|
||||
|
||||
cag_bar = cag_bar.resize((w, new_cag_h))
|
||||
|
||||
img.paste(
|
||||
cag_bar,
|
||||
(0, int(new_banner_h + hs - 26 * bscale)),
|
||||
cag_bar,
|
||||
)
|
||||
|
||||
for i, command in enumerate(cag_data):
|
||||
command_name = command['name']
|
||||
@ -179,31 +244,50 @@ async def get_new_help(
|
||||
command_eg = command['eg']
|
||||
command_bg = deepcopy(item_bg)
|
||||
|
||||
icon = find_icon(command_name, icon_path)
|
||||
if 'icon' in command:
|
||||
if isinstance(command['icon'], Image.Image):
|
||||
icon: Image.Image = command['icon']
|
||||
else:
|
||||
icon = Image.open(command['icon'])
|
||||
else:
|
||||
icon = find_icon(command_name, icon_path)
|
||||
|
||||
if icon.width > 200:
|
||||
icon = icon.resize((128, 128))
|
||||
_icon = Image.new('RGBA', (150, 150))
|
||||
_icon.paste(icon, (11, 11), icon)
|
||||
icon = _icon
|
||||
else:
|
||||
icon = icon.resize((150, 150))
|
||||
command_bg.paste(icon, (6, 12), icon)
|
||||
|
||||
command_draw = ImageDraw.Draw(command_bg)
|
||||
|
||||
_command_name = calculate_string_length(command_name)
|
||||
|
||||
command_draw.text(
|
||||
(160, 67),
|
||||
plugin_prefix + command_name,
|
||||
(156, 67),
|
||||
_command_name,
|
||||
main_color,
|
||||
font=core_font(40),
|
||||
font=core_font(38),
|
||||
anchor='lm',
|
||||
)
|
||||
|
||||
command_draw.text(
|
||||
(160, 116),
|
||||
(156, 116),
|
||||
plugin_prefix + command_eg,
|
||||
sub_color,
|
||||
font=core_font(26),
|
||||
anchor='lm',
|
||||
)
|
||||
|
||||
x, y = 45 + (i % 3) * 490, 370 + (i // 3) * 175 + hs
|
||||
x, y = (
|
||||
45 + (i % column) * 490,
|
||||
int(new_banner_h + 70 * bscale + (i // column) * 175 + hs),
|
||||
)
|
||||
img.paste(command_bg, (x, y), command_bg)
|
||||
|
||||
hs += (((len(cag_data) - 1) // 3) + 1) * 175 + 100
|
||||
hs += (((len(cag_data) - 1) // column) + 1) * 175 + new_cag_h
|
||||
|
||||
img.paste(
|
||||
footer,
|
||||
|
62
gsuid_core/help/help.json
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"Mihomo账户登陆": {
|
||||
"desc": "在执行查询之前请绑定账号",
|
||||
"data": [
|
||||
{
|
||||
"name": "扫码登陆",
|
||||
"desc": "绑定自己的账户",
|
||||
"eg": "扫码登陆",
|
||||
"need_ck": false,
|
||||
"need_sk": false,
|
||||
"need_admin": false
|
||||
},
|
||||
{
|
||||
"name": "添加CK",
|
||||
"desc": "手动添加CK, 仅限私聊",
|
||||
"eg": "添加CK ltuid=xxx",
|
||||
"need_ck": false,
|
||||
"need_sk": false,
|
||||
"need_admin": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"MiHoMo账户管理": {
|
||||
"desc": "在执行查询之前请绑定账号",
|
||||
"data": [
|
||||
{
|
||||
"name": "刷新CK",
|
||||
"desc": "通过SK去刷新CK",
|
||||
"eg": "刷新CK",
|
||||
"need_ck": false,
|
||||
"need_sk": false,
|
||||
"need_admin": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"设备绑定": {
|
||||
"desc": "账户关联设备信息",
|
||||
"data": [
|
||||
{
|
||||
"name": "绑定设备",
|
||||
"desc": "仅限私聊绑定设备",
|
||||
"eg": "mys绑定设备",
|
||||
"need_ck": true,
|
||||
"need_sk": false,
|
||||
"need_admin": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"账户绑定检查": {
|
||||
"desc": "账户关联设备信息",
|
||||
"data": [
|
||||
{
|
||||
"name": "绑定信息",
|
||||
"desc": "检查自己在所有插件下的绑定信息",
|
||||
"eg": "绑定信息",
|
||||
"need_ck": false,
|
||||
"need_sk": false,
|
||||
"need_admin": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
147
gsuid_core/help/master_help.json
Normal file
@ -0,0 +1,147 @@
|
||||
{
|
||||
"管理插件": {
|
||||
"desc": "安装/管理插件",
|
||||
"data": [
|
||||
{
|
||||
"name": "刷新插件列表",
|
||||
"desc": "可以同步最新的插件列表",
|
||||
"eg": "刷新插件列表",
|
||||
"need_ck": false,
|
||||
"need_sk": false,
|
||||
"need_admin": true
|
||||
},
|
||||
{
|
||||
"name": "安装插件",
|
||||
"desc": "安装插件",
|
||||
"eg": "安装插件Pokemon",
|
||||
"need_ck": false,
|
||||
"need_sk": false,
|
||||
"need_admin": true
|
||||
},
|
||||
{
|
||||
"name": "卸载插件",
|
||||
"desc": "卸载插件",
|
||||
"eg": "卸载插件Pokemon",
|
||||
"need_ck": false,
|
||||
"need_sk": false,
|
||||
"need_admin": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"更新插件": {
|
||||
"desc": "更新插件",
|
||||
"data": [
|
||||
{
|
||||
"name": "更新插件",
|
||||
"desc": "更新插件",
|
||||
"eg": "更新插件Pokemon",
|
||||
"need_ck": true,
|
||||
"need_sk": false,
|
||||
"need_admin": false
|
||||
},
|
||||
{
|
||||
"name": "强制更新插件",
|
||||
"desc": "强制reset之后更新插件",
|
||||
"eg": "强制更新插件",
|
||||
"need_ck": false,
|
||||
"need_sk": false,
|
||||
"need_admin": false
|
||||
},
|
||||
{
|
||||
"name": "强行强制更新插件",
|
||||
"desc": "强制reset+clean之后更新插件",
|
||||
"eg": "强行强制更新插件",
|
||||
"need_ck": false,
|
||||
"need_sk": false,
|
||||
"need_admin": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"核心管理": {
|
||||
"desc": "启停核心",
|
||||
"data": [
|
||||
{
|
||||
"name": "重启",
|
||||
"desc": "重启核心",
|
||||
"eg": "重启",
|
||||
"need_ck": false,
|
||||
"need_sk": false,
|
||||
"need_admin": false
|
||||
},
|
||||
{
|
||||
"name": "关闭",
|
||||
"desc": "警告:关闭后将无法通过命令调用",
|
||||
"eg": "关闭",
|
||||
"need_ck": true,
|
||||
"need_sk": false,
|
||||
"need_admin": false
|
||||
},
|
||||
{
|
||||
"name": "状态",
|
||||
"desc": "查看目前核心的状态",
|
||||
"eg": "状态",
|
||||
"need_ck": false,
|
||||
"need_sk": false,
|
||||
"need_admin": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"MiHoMo核心": {
|
||||
"desc": "管理用户",
|
||||
"data": [
|
||||
{
|
||||
"name": "刷新全部CK",
|
||||
"desc": "刷新全部用户的CK",
|
||||
"eg": "刷新全部CK",
|
||||
"need_ck": false,
|
||||
"need_sk": false,
|
||||
"need_admin": true
|
||||
},
|
||||
{
|
||||
"name": "校验全部CK",
|
||||
"desc": "校验全部ck的状态",
|
||||
"eg": "校验全部CK",
|
||||
"need_ck": false,
|
||||
"need_sk": false,
|
||||
"need_admin": false
|
||||
},
|
||||
{
|
||||
"name": "校验全部SK",
|
||||
"desc": "校验全部sk的状态",
|
||||
"eg": "校验全部SK",
|
||||
"need_ck": false,
|
||||
"need_sk": false,
|
||||
"need_admin": false
|
||||
},
|
||||
{
|
||||
"name": "清除无效用户",
|
||||
"desc": "清理失效的用户",
|
||||
"eg": "清除无效用户",
|
||||
"need_ck": false,
|
||||
"need_sk": false,
|
||||
"need_admin": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"杂项": {
|
||||
"desc": "一些可能会有用的功能",
|
||||
"data": [
|
||||
{
|
||||
"name": "重置网页控制台密码",
|
||||
"desc": "重置网页控制台密码",
|
||||
"eg": "重置网页控制台密码",
|
||||
"need_ck": false,
|
||||
"need_sk": false,
|
||||
"need_admin": false
|
||||
},
|
||||
{
|
||||
"name": "给我发消息",
|
||||
"desc": "给主人发送一条主动消息",
|
||||
"eg": "给我发消息",
|
||||
"need_ck": true,
|
||||
"need_sk": false,
|
||||
"need_admin": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
BIN
gsuid_core/help/new_icon/CK.png
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
gsuid_core/help/new_icon/七圣.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
gsuid_core/help/new_icon/伤害.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
gsuid_core/help/new_icon/佳期.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
gsuid_core/help/new_icon/充值.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
gsuid_core/help/new_icon/全部重签.png
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
gsuid_core/help/new_icon/公告.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
gsuid_core/help/new_icon/关闭.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
gsuid_core/help/new_icon/切换.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
gsuid_core/help/new_icon/删除.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
gsuid_core/help/new_icon/刷新.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
gsuid_core/help/new_icon/刷新CK.png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
gsuid_core/help/new_icon/刷新抽卡记录.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
gsuid_core/help/new_icon/刷新插件列表.png
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
gsuid_core/help/new_icon/刷新面板.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
gsuid_core/help/new_icon/卡池.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
gsuid_core/help/new_icon/卡池列表.png
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
gsuid_core/help/new_icon/卡组.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
gsuid_core/help/new_icon/卸载插件.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
gsuid_core/help/new_icon/原石.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
gsuid_core/help/new_icon/原魔.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
gsuid_core/help/new_icon/圣遗物.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
gsuid_core/help/new_icon/圣遗物仓库.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
gsuid_core/help/new_icon/天赋.png
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
gsuid_core/help/new_icon/委托.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
gsuid_core/help/new_icon/安装插件.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
gsuid_core/help/new_icon/完成度.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
gsuid_core/help/new_icon/宝箱.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
gsuid_core/help/new_icon/小助手.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
gsuid_core/help/new_icon/开启体力推送.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
gsuid_core/help/new_icon/强制更新插件.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
gsuid_core/help/new_icon/强行强制更新插件.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
gsuid_core/help/new_icon/御神签.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
gsuid_core/help/new_icon/怪物.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
gsuid_core/help/new_icon/成就.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
gsuid_core/help/new_icon/扫码登陆.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
gsuid_core/help/new_icon/抗性.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
gsuid_core/help/new_icon/抽卡记录.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
gsuid_core/help/new_icon/换.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
gsuid_core/help/new_icon/排名.png
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
gsuid_core/help/new_icon/探索.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
gsuid_core/help/new_icon/推送.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
gsuid_core/help/new_icon/收集.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
gsuid_core/help/new_icon/攻略.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
gsuid_core/help/new_icon/无效用户.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
gsuid_core/help/new_icon/更新.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
gsuid_core/help/new_icon/更新插件.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
gsuid_core/help/new_icon/札记.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
gsuid_core/help/new_icon/查询.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
gsuid_core/help/new_icon/校验全部SK.png
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
gsuid_core/help/new_icon/武器.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
gsuid_core/help/new_icon/每日.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
gsuid_core/help/new_icon/每月.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
gsuid_core/help/new_icon/毕业度.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
gsuid_core/help/new_icon/注册时间.png
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
gsuid_core/help/new_icon/活动.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
gsuid_core/help/new_icon/深渊.png
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
gsuid_core/help/new_icon/添加CK.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
gsuid_core/help/new_icon/清除原神公告红点.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
gsuid_core/help/new_icon/清除无效用户.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
gsuid_core/help/new_icon/版本深渊.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
gsuid_core/help/new_icon/状态.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
gsuid_core/help/new_icon/签到.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
gsuid_core/help/new_icon/米游币.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
gsuid_core/help/new_icon/素材.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
gsuid_core/help/new_icon/练度.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
gsuid_core/help/new_icon/绑定.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
gsuid_core/help/new_icon/绑定设备.png
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
gsuid_core/help/new_icon/结晶.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
gsuid_core/help/new_icon/网页控制台.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
gsuid_core/help/new_icon/自动签到.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
gsuid_core/help/new_icon/血量.png
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
gsuid_core/help/new_icon/血量表.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
gsuid_core/help/new_icon/表情.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
gsuid_core/help/new_icon/角色.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
gsuid_core/help/new_icon/角色排名.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
gsuid_core/help/new_icon/角色排行榜.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
gsuid_core/help/new_icon/角色材料.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
gsuid_core/help/new_icon/设置体力阈值.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
gsuid_core/help/new_icon/通用.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
gsuid_core/help/new_icon/配置.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
gsuid_core/help/new_icon/重启.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
gsuid_core/help/new_icon/食物.png
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
gsuid_core/help/texture2d/banner_bg_dark.jpg
Normal file
After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
BIN
gsuid_core/help/texture2d/bg_dark.jpg
Normal file
After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 158 KiB After Width: | Height: | Size: 158 KiB |
Before Width: | Height: | Size: 888 B |
BIN
gsuid_core/help/texture2d/cag_bg_dark.png
Normal file
After Width: | Height: | Size: 895 B |
BIN
gsuid_core/help/texture2d/cag_bg_light.png
Normal file
After Width: | Height: | Size: 894 B |
BIN
gsuid_core/help/texture2d/item_bg_dark.png
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
gsuid_core/help/texture2d/item_bg_light.png
Normal file
After Width: | Height: | Size: 31 KiB |
29
gsuid_core/help/utils.py
Normal file
@ -0,0 +1,29 @@
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from PIL import Image
|
||||
|
||||
ICON = Path(__file__).parent.parent.parent / 'ICON.png'
|
||||
plugins_help = {
|
||||
"插件帮助一览": {"desc": "这里可以看到注册过的插件帮助。", "data": []},
|
||||
}
|
||||
|
||||
|
||||
def register_help(
|
||||
name: str,
|
||||
help: str,
|
||||
icon: Optional[Image.Image] = None,
|
||||
):
|
||||
if icon is None:
|
||||
icon = Image.open(ICON)
|
||||
plugins_help['插件帮助一览']['data'].append(
|
||||
{
|
||||
"name": name,
|
||||
"desc": f"{name}插件帮助功能",
|
||||
"eg": f'发送 {help} 获得帮助',
|
||||
"icon": icon,
|
||||
"need_ck": False,
|
||||
"need_sk": False,
|
||||
"need_admin": False,
|
||||
}
|
||||
)
|
@ -2,11 +2,30 @@ from gsuid_core.sv import SV
|
||||
from gsuid_core.bot import Bot
|
||||
from gsuid_core.models import Event
|
||||
from gsuid_core.logger import logger
|
||||
from gsuid_core.help.draw_core_help import draw_core_help, draw_master_help
|
||||
|
||||
sv_core_help_img = SV('Core帮助')
|
||||
|
||||
|
||||
@sv_core_help_img.on_fullmatch(('core帮助', 'Core帮助'))
|
||||
async def send_core_htlp_msg(bot: Bot, ev: Event):
|
||||
@sv_core_help_img.on_fullmatch(
|
||||
(
|
||||
'core帮助',
|
||||
'Core帮助',
|
||||
'帮助',
|
||||
)
|
||||
)
|
||||
async def send_core_help_msg(bot: Bot, ev: Event):
|
||||
logger.info('[早柚核心] 开始执行[帮助图]')
|
||||
await bot.send('该功能已删除...')
|
||||
await bot.send(await draw_core_help())
|
||||
|
||||
|
||||
@sv_core_help_img.on_fullmatch(
|
||||
(
|
||||
'core管理帮助',
|
||||
'Core管理帮助',
|
||||
'管理帮助',
|
||||
)
|
||||
)
|
||||
async def send_core_master_help_msg(bot: Bot, ev: Event):
|
||||
logger.info('[早柚核心] 开始执行[管理帮助图]')
|
||||
await bot.send(await draw_master_help())
|
||||
|
@ -6,9 +6,38 @@ from gsuid_core.utils.plugins_update._plugins import (
|
||||
update_plugins,
|
||||
get_plugins_url,
|
||||
install_plugins,
|
||||
uninstall_plugin,
|
||||
check_plugin_exist,
|
||||
)
|
||||
|
||||
sv_core_install_plugins = SV('core管理插件', pm=1)
|
||||
sv_core_install_plugins = SV('core管理插件', pm=0)
|
||||
|
||||
|
||||
@sv_core_install_plugins.on_prefix(('core卸载插件'))
|
||||
async def send_plugins_uninstall(bot: Bot, ev: Event):
|
||||
if not ev.text:
|
||||
return await bot.send(
|
||||
'请在命令之后加上要卸载插件名称!\n例如: core卸载插件GenshinUID'
|
||||
)
|
||||
plugin_name = ev.text.strip()
|
||||
path = await check_plugin_exist(plugin_name)
|
||||
if path is None:
|
||||
return await bot.send('不存在该插件...请检查是否输入正确!')
|
||||
elif isinstance(path, str):
|
||||
return await bot.send(path)
|
||||
|
||||
resp = await bot.receive_resp(
|
||||
'再次确认是否要删除插件文件夹?\n输入Y确认删除!',
|
||||
)
|
||||
if resp is not None:
|
||||
if resp.text.lower() == 'y':
|
||||
await bot.send('开始删除...请稍等一段时间...')
|
||||
im = await uninstall_plugin(path)
|
||||
await bot.send(im)
|
||||
else:
|
||||
await bot.send('已取消删除!')
|
||||
else:
|
||||
await bot.send('已取消删除!')
|
||||
|
||||
|
||||
@sv_core_install_plugins.on_prefix(('core安装插件'))
|
||||
|
@ -1,5 +1,7 @@
|
||||
import json
|
||||
from typing import Dict
|
||||
import random
|
||||
import asyncio
|
||||
from typing import Dict, List
|
||||
|
||||
from gsuid_core.sv import SV
|
||||
from gsuid_core.bot import Bot
|
||||
@ -16,10 +18,11 @@ from gsuid_core.utils.cookie_manager.add_ck import (
|
||||
get_ck_by_all_stoken,
|
||||
)
|
||||
|
||||
sv_core_user_config = SV('用户管理', pm=2)
|
||||
sv_core_user_config = SV('用户管理', pm=1)
|
||||
sv_core_user_add = SV('用户添加')
|
||||
sv_core_user_qrcode_login = SV('扫码登陆')
|
||||
sv_core_user_addck = SV('添加CK', area='DIRECT')
|
||||
sv_data_manger = SV('用户数据管理', pm=0)
|
||||
|
||||
|
||||
@sv_core_user_config.on_fullmatch(('刷新全部CK', '刷新全部ck'))
|
||||
@ -36,6 +39,109 @@ async def send_refresh_ck_msg(bot: Bot, ev: Event):
|
||||
await bot.send(im)
|
||||
|
||||
|
||||
@sv_data_manger.on_fullmatch(('校验全部Cookies'))
|
||||
async def send_check_cookie(bot: Bot, ev: Event):
|
||||
user_list = await GsUser.get_all_user()
|
||||
invalid_user: List[GsUser] = []
|
||||
for user in user_list:
|
||||
if user.cookie and user.mys_id and user.uid:
|
||||
mys_data = await mys_api.get_mihoyo_bbs_info(
|
||||
user.mys_id,
|
||||
user.cookie,
|
||||
True if int(user.uid[0]) > 5 else False,
|
||||
)
|
||||
if isinstance(mys_data, int):
|
||||
await GsUser.update_data_by_uid(
|
||||
user.uid, ev.bot_id, cookie=None
|
||||
)
|
||||
invalid_user.append(user)
|
||||
continue
|
||||
for i in mys_data:
|
||||
if i['game_id'] != 2:
|
||||
mys_data.remove(i)
|
||||
if len(user_list) > 4:
|
||||
im = f'正常Cookies数量: {len(user_list) - len(invalid_user)}'
|
||||
invalid = '\n'.join(
|
||||
[
|
||||
f'uid{user.uid}的Cookies是异常的!已删除该条Cookies!\n'
|
||||
for user in invalid_user
|
||||
]
|
||||
)
|
||||
return_str = f'{im}\n{invalid if invalid else "无失效Cookie!"}'
|
||||
else:
|
||||
return_str = '\n'.join(
|
||||
[
|
||||
(
|
||||
f'uid{user.uid}/mys{user.mys_id}的Cookies是正常的!'
|
||||
if user not in invalid_user
|
||||
else f'uid{user.uid}的Cookies是异常的!已删除该条Cookies!'
|
||||
)
|
||||
for user in user_list
|
||||
]
|
||||
)
|
||||
|
||||
await bot.send(return_str)
|
||||
|
||||
for i in invalid_user:
|
||||
await bot.target_send(
|
||||
f'您绑定的Cookies(uid{i.uid})已失效,以下功能将会受到影响:\n'
|
||||
'查看完整信息列表\n查看深渊配队\n自动签到/当前状态/每月统计\n'
|
||||
'请及时重新绑定Cookies并重新开关相应功能。',
|
||||
'direct',
|
||||
target_id=i.user_id,
|
||||
)
|
||||
await asyncio.sleep(3 + random.randint(1, 3))
|
||||
|
||||
|
||||
@sv_data_manger.on_fullmatch(('校验全部Stoken'))
|
||||
async def send_check_stoken(bot: Bot, ev: Event):
|
||||
user_list = await GsUser.get_all_user()
|
||||
invalid_user: List[GsUser] = []
|
||||
for user in user_list:
|
||||
if user.stoken and user.mys_id:
|
||||
mys_data = await mys_api.get_cookie_token_by_stoken(
|
||||
'', user.mys_id, user.stoken
|
||||
)
|
||||
if isinstance(mys_data, int) and user.uid:
|
||||
await GsUser.update_data_by_uid(
|
||||
user.uid, ev.bot_id, stoken=None
|
||||
)
|
||||
invalid_user.append(user)
|
||||
continue
|
||||
if len(user_list) > 3:
|
||||
im = f'正常Stoken数量: {len(user_list) - len(invalid_user)}'
|
||||
invalid = '\n'.join(
|
||||
[
|
||||
f'uid{user.uid}的Stoken是异常的!已清除Stoken!\n'
|
||||
for user in invalid_user
|
||||
]
|
||||
)
|
||||
return_str = f'{im}\n{invalid if invalid else "无失效Stoken!"}'
|
||||
else:
|
||||
return_str = '\n'.join(
|
||||
[
|
||||
(
|
||||
f'uid{user.uid}/mys{user.mys_id}的Stoken是正常的!'
|
||||
if user not in invalid_user
|
||||
else f'uid{user.uid}的Stoken是异常的!已清除Stoken!'
|
||||
)
|
||||
for user in user_list
|
||||
]
|
||||
)
|
||||
|
||||
await bot.send(return_str)
|
||||
|
||||
for i in invalid_user:
|
||||
await bot.target_send(
|
||||
f'您绑定的Stoken(uid{i.uid})已失效,以下功能将会受到影响:\n'
|
||||
'gs开启自动米游币,开始获取米游币。\n'
|
||||
'重新添加后需要重新开启自动米游币。',
|
||||
'direct',
|
||||
target_id=i.user_id,
|
||||
)
|
||||
await asyncio.sleep(3 + random.randint(1, 3))
|
||||
|
||||
|
||||
async def _send_help(bot: Bot, im):
|
||||
p = Button('🔍查询信息', '查询')
|
||||
q = Button('💠查询探索度', '查询探索')
|
||||
|