Skip to content

Commit

Permalink
✨ 更新ba帮助, 并适配新的前缀系统
Browse files Browse the repository at this point in the history
  • Loading branch information
KimigaiiWuyi committed Oct 4, 2024
1 parent 50606bf commit d72f456
Show file tree
Hide file tree
Showing 35 changed files with 144 additions and 80 deletions.
6 changes: 3 additions & 3 deletions BlueArchiveUID/bauid_guide/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
char_source: List[str] = ba_config.get_config('char_guide_source').data


@sv_ba_wiki.on_prefix(('ba角色攻略', 'BA角色攻略'))
@sv_ba_wiki.on_prefix(('角色攻略'))
async def send_ba_char_pic(bot: Bot, ev: Event):
msg_list = []
for s in char_source:
Expand All @@ -34,7 +34,7 @@ async def send_ba_char_pic(bot: Bot, ev: Event):
await bot.send('未找到相关的攻略信息!')


@sv_ba_guide.on_prefix(('ba攻略', 'BA攻略'))
@sv_ba_guide.on_prefix(('攻略'))
async def send_ba_stage_pic(bot: Bot, ev: Event):
im = await get_guide_img(ev.text)
if isinstance(im, str):
Expand All @@ -44,6 +44,6 @@ async def send_ba_stage_pic(bot: Bot, ev: Event):
await bot.send(img)


@sv_ba_guide.on_fullmatch(('ba活动攻略', 'BA活动攻略'))
@sv_ba_guide.on_fullmatch(('活动攻略'))
async def send_event_guide_pic(bot: Bot, ev: Event):
await bot.send(await get_event_img())
94 changes: 76 additions & 18 deletions BlueArchiveUID/bauid_help/Help.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,96 @@
"desc": "一些基础的查询功能",
"data": [
{
"name": "ba攻略",
"name": "攻略",
"desc": "获取主线任务走格子攻略",
"eg": "ba攻略16-3H",
"eg": "攻略16-3H",
"need_ck": false,
"need_sk": false,
"need_admin": false
},
{
"name": "ba角色攻略",
"desc": "获取BA的角色的养成攻略",
"eg": "ba角色攻略优香",
"name": "角色攻略",
"desc": "获取的角色的养成攻略",
"eg": "角色攻略优香",
"need_ck": false,
"need_sk": false,
"need_admin": false
},
{
"name": "ba活动攻略",
"name": "活动攻略",
"desc": "获取当期活动攻略",
"eg": "ba活动攻略",
"eg": "活动攻略",
"need_ck": false,
"need_sk": false,
"need_admin": false
}
]
},
"什亭之匣相关": {
"总力战相关": {
"desc": "数据来源arona.icu,需要申请Token使用",
"data": [
{
"name": "ba总力战",
"name": "总力战",
"desc": "获取当期国服总力战的档线信息",
"eg": "ba总力战",
"eg": "总力战",
"need_ck": false,
"need_sk": false,
"need_admin": false
},
{
"name": "ba总力战b",
"name": "总力战b",
"desc": "获取当期B服总力战的档线信息",
"eg": "ba总力战b",
"eg": "总力战b",
"need_ck": false,
"need_sk": false,
"need_admin": false
}
]
},
"绑定好友码": {
"desc": "在执行查询之前请绑定账号",
"data": [
{
"name": "绑定好友码",
"desc": "绑定自己的账户",
"eg": "绑定好友码vlhy4mw:1",
"need_ck": false,
"need_sk": false,
"need_admin": false
},
{
"name": "切换好友码",
"desc": "切换绑定的账户",
"eg": "切换好友码",
"need_ck": true,
"need_sk": false,
"need_admin": false
},
{
"name": "删除好友码",
"desc": "解除绑定",
"eg": "删除好友码vlhy4mw:1",
"need_ck": false,
"need_sk": false,
"need_admin": false
}
]
},
"信息查询相关": {
"desc": "数据来源arona.icu,请在使用前进行【绑定】",
"data": [
{
"name": "查询",
"desc": "获取当期国服总力战的档线信息",
"eg": "查询vlhy4mw:1",
"need_ck": false,
"need_sk": false,
"need_admin": false
},
{
"name": "角色排名",
"desc": "获取全服的角色好感排名",
"eg": "角色排名星野",
"need_ck": false,
"need_sk": false,
"need_admin": false
Expand All @@ -53,17 +103,25 @@
"desc": "一些和计算相关的服务",
"data": [
{
"name": "ba用时",
"name": "用时",
"desc": "根据分数计算用时",
"eg": "ba用时寿司1300w",
"eg": "用时寿司1300w",
"need_ck": false,
"need_sk": false,
"need_admin": false
},
{
"name": "ba算分",
"name": "算分",
"desc": "根据时间计算分数",
"eg": "ba算分ex寿司剩1:23.43",
"eg": "算分ex寿司剩1:23.43",
"need_ck": false,
"need_sk": false,
"need_admin": false
},
{
"name": "jjc挖矿",
"desc": "计算竞技场挖矿数量",
"eg": "jjc挖矿",
"need_ck": false,
"need_sk": false,
"need_admin": false
Expand All @@ -74,9 +132,9 @@
"desc": "一些杂项服务",
"data": [
{
"name": "ba帮助",
"name": "帮助",
"desc": "呼出该帮助界面",
"eg": "ba帮助",
"eg": "帮助",
"need_ck": false,
"need_sk": false,
"need_admin": false
Expand Down
6 changes: 3 additions & 3 deletions BlueArchiveUID/bauid_help/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
from gsuid_core.logger import logger
from gsuid_core.help.utils import register_help

from .get_help import ICON, get_ba_core_help
from .get_help import ICON, get_help

sv_ba_help = SV('BA帮助')


@sv_ba_help.on_fullmatch(('ba帮助', '蔚蓝档案帮助', 'BA帮助'))
@sv_ba_help.on_fullmatch(('帮助', '蔚蓝档案帮助'))
async def send_help_img(bot: Bot, ev: Event):
logger.info('开始执行[ba帮助]')
im = await get_ba_core_help()
im = await get_help()
await bot.send(im)


Expand Down
63 changes: 26 additions & 37 deletions BlueArchiveUID/bauid_help/get_help.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,40 @@
from typing import Dict
from pathlib import Path
from typing import Dict, Union

import aiofiles
from PIL import Image
from msgspec import json as msgjson
from gsuid_core.help.model import PluginHelp
from gsuid_core.utils.fonts.fonts import core_font
from gsuid_core.help.draw_plugin_help import get_help
from gsuid_core.help.draw_new_plugin_help import get_new_help

from ..utils.image import get_footer
from ..version import BlueArchiveUID_version

ICON = Path(__file__).parent.parent.parent / 'ICON.png'
HELP_DATA = Path(__file__).parent / 'help.json'
ICON_PATH = Path(__file__).parent / 'icon_path'
TEXT_PATH = Path(__file__).parent / 'texture2d'
HELP_DATA = Path(__file__).parent / 'Help.json'


async def get_help_data() -> Union[Dict[str, PluginHelp], None]:
if HELP_DATA.exists():
async with aiofiles.open(HELP_DATA, 'rb') as file:
return msgjson.decode(
await file.read(),
type=Dict[str, PluginHelp],
)


async def get_ba_core_help() -> Union[bytes, str]:
help_data = await get_help_data()
if help_data is None:
return '暂未找到帮助数据...'

img = await get_help(
'BlueArchiveUID',
f'版本号:{BlueArchiveUID_version}',
help_data,
Image.open(TEXT_PATH / 'bg.jpg'),
Image.open(TEXT_PATH / 'icon.png'),
Image.open(TEXT_PATH / 'badge.png'),
Image.open(TEXT_PATH / 'banner.png'),
Image.open(TEXT_PATH / 'button.png'),
core_font,
is_dark=False,
column=4,
is_gaussian=True,
gaussian_blur=10,
text_color=(39, 87, 168),
sub_c=(68, 128, 230),
sv_color=(8, 8, 8),
sv_desc_color=(58, 58, 58),
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 get_help():
return await get_new_help(
plugin_name='BlueArchiveUID',
plugin_info={f'v{BlueArchiveUID_version}': ''},
plugin_icon=Image.open(ICON),
plugin_help=await get_help_data(),
plugin_prefix='ba',
help_mode='light',
banner_bg=Image.open(TEXT_PATH / 'banner_bg.jpg'),
banner_sub_text='「与你的日常,就是“奇迹”」',
help_bg=Image.open(TEXT_PATH / 'bg.jpg'),
cag_bg=Image.open(TEXT_PATH / 'cag_bg.png'),
item_bg=Image.open(TEXT_PATH / 'item.png'),
icon_path=ICON_PATH,
footer=get_footer(),
enable_cache=True,
)
return img
Binary file added BlueArchiveUID/bauid_help/icon_path/切换.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BlueArchiveUID/bauid_help/icon_path/删除.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BlueArchiveUID/bauid_help/icon_path/帮助.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BlueArchiveUID/bauid_help/icon_path/总力战.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BlueArchiveUID/bauid_help/icon_path/挖矿.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BlueArchiveUID/bauid_help/icon_path/攻略.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BlueArchiveUID/bauid_help/icon_path/查询.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BlueArchiveUID/bauid_help/icon_path/用时.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BlueArchiveUID/bauid_help/icon_path/算分.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BlueArchiveUID/bauid_help/icon_path/绑定.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BlueArchiveUID/bauid_help/icon_path/通用.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed BlueArchiveUID/bauid_help/texture2d/badge.png
Binary file not shown.
Binary file removed BlueArchiveUID/bauid_help/texture2d/banner.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified BlueArchiveUID/bauid_help/texture2d/bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed BlueArchiveUID/bauid_help/texture2d/button.png
Binary file not shown.
Binary file added BlueArchiveUID/bauid_help/texture2d/cag_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed BlueArchiveUID/bauid_help/texture2d/icon.png
Binary file not shown.
Binary file added BlueArchiveUID/bauid_help/texture2d/item.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion BlueArchiveUID/bauid_info/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
ba_user_info = SV('ba用户信息')


@ba_user_info.on_command(('ba查询'), block=True)
@ba_user_info.on_command(('查询'), block=True)
async def send_ba_user_info(bot: Bot, ev: Event):
fcode, user_id = await get_uid(
bot, ev, BaBind, partten=r'[A-Za-z0-9::]+', get_user_id=True
Expand Down
3 changes: 2 additions & 1 deletion BlueArchiveUID/bauid_raid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
sv_ba_xtzx_raid = SV('BA什亭之匣总力战')


# 无用
@sv_ba_raid.on_command(('总力战档位'))
async def send_raid_msg(bot: Bot, ev: Event):
match = re.search(r'\d+', ev.text)
season = match.group() if match else None
await bot.send(await get_ranking(season))


@sv_ba_xtzx_raid.on_command(('ba总力战', 'BA总力战', 'ba档线', 'ba挡线'))
@sv_ba_xtzx_raid.on_command(('总力战', '档线', '挡线'))
async def send_xtzx_msg(bot: Bot, ev: Event):
if 'B' in ev.text or 'b' in ev.text:
server_id = 2
Expand Down
8 changes: 4 additions & 4 deletions BlueArchiveUID/bauid_ranklist/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

@sv_ba_xtzx_rank.on_command(
(
'ba学生排行',
'ba学生排名',
'ba角色排名',
'ba角色排行',
'学生排行',
'学生排名',
'角色排名',
'角色排行',
)
)
async def send_rank_msg(bot: Bot, ev: Event):
Expand Down
4 changes: 2 additions & 2 deletions BlueArchiveUID/bauid_score/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
sv_ba_time = SV('BA总力战算用时')


@sv_ba_score.on_command(('ba算分', 'BA算分'))
@sv_ba_score.on_command(('算分'))
async def send_score_msg(bot: Bot, ev: Event):
if not ev.text:
await bot.send(
Expand All @@ -30,7 +30,7 @@ async def send_score_msg(bot: Bot, ev: Event):
await bot.send('请检查指令词 用时/算分 或格式 用/剩,重新发送指令')


@sv_ba_time.on_command(('ba用时', 'BA用时'))
@sv_ba_time.on_command(('用时'))
async def send_time_msg(bot: Bot, ev: Event):
if not ev.text:
await bot.send(
Expand Down
20 changes: 10 additions & 10 deletions BlueArchiveUID/bauid_user/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@

@ba_user_bind.on_command(
(
'ba绑定uid',
'ba绑定UID',
'ba绑定',
'ba好友码',
'ba切换uid',
'ba切换UID',
'ba切换',
'ba删除uid',
'ba删除UID',
'ba删除',
'绑定uid',
'绑定UID',
'绑定',
'好友码',
'切换uid',
'切换UID',
'切换',
'删除uid',
'删除UID',
'删除',
),
block=True,
)
Expand Down
9 changes: 9 additions & 0 deletions BlueArchiveUID/utils/image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from pathlib import Path

from PIL import Image

TEXT_PATH = Path(__file__).parent / 'texture2d'


def get_footer():
return Image.open(TEXT_PATH / 'footer.png')
Binary file added BlueArchiveUID/utils/texture2d/footer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion BlueArchiveUID/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BlueArchiveUID_version = '0.2'
BlueArchiveUID_version = '0.3'
7 changes: 7 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from gsuid_core.sv import Plugins

Plugins(
name="BlueArchiveUID",
force_prefix=["ba", "BA"],
allow_empty_prefix=False,
)

0 comments on commit d72f456

Please sign in to comment.