添加更多按钮

This commit is contained in:
KimigaiiWuyi 2023-12-06 03:10:53 +08:00
parent a9b4dda8cb
commit c90c393187
5 changed files with 36 additions and 5 deletions

View File

@ -71,7 +71,15 @@ async def send_abyss_review(bot: Bot, ev: Event):
im = await get_review(version)
if isinstance(im, bytes):
await bot.send(im)
c = Button('♾️深渊概览', '深渊概览')
input_version = float(version)
now_version = float(Genshin_version[:-2])
if input_version <= now_version:
adv_version = now_version + 0.1
else:
adv_version = now_version
d = Button(f'♾️版本深渊{adv_version}', f'深渊概览{adv_version}')
await bot.send_option(im, [c, d])
elif isinstance(im, List):
mes = [MessageSegment.text(msg) for msg in im]
await bot.send(MessageSegment.node(mes))

View File

@ -8,7 +8,7 @@ from ..utils.resource.download_all_resource import download_all_resource
sv_download_config = SV('下载资源', pm=2)
@sv_download_config.on_fullmatch(('下载全部资源'))
@sv_download_config.on_fullmatch(('下载全部资源', 'gs下载全部资源'))
async def send_download_resource_msg(bot: Bot, ev: Event):
await bot.send('正在开始下载~可能需要较久的时间!')
im = await download_all_resource()

View File

@ -1,6 +1,7 @@
from gsuid_core.sv import SV
from gsuid_core.bot import Bot
from gsuid_core.models import Event
from gsuid_core.message_models import Button
from gsuid_core.segment import MessageSegment
from gsuid_core.utils.database.models import GsBind
@ -21,6 +22,14 @@ async def send_link_uid_msg(bot: Bot, ev: Event):
if uid and not uid.isdigit():
return await bot.send('你输入了错误的格式!')
a = Button('🔍查询探索', '查询探索')
b = Button('🔍查询收集', '查询收集')
c = Button('💖刷新面板', '刷新面板')
d2 = Button('🔔绑定UID', '绑定uid')
d = Button('🔔绑定更多UID', '绑定uid')
e = Button('🔄切换UID', '切换UID')
f = Button('❌删除uid', '删除uid')
if '绑定' in ev.command:
data = await GsBind.insert_uid(qid, ev.bot_id, uid, ev.group_id, 9)
return await send_diff_msg(
@ -32,6 +41,7 @@ async def send_link_uid_msg(bot: Bot, ev: Event):
-2: f'UID{uid}已经绑定过了!',
-3: '你输入了错误的格式!',
},
[[d, e, f], [a, b, c]],
)
elif '切换' in ev.command:
data = await GsBind.switch_uid_by_game(qid, ev.bot_id, uid)
@ -44,6 +54,7 @@ async def send_link_uid_msg(bot: Bot, ev: Event):
-2: f'UID{uid}不在绑定列表中!',
-3: '请绑定大于等于两个UID以进行切换!',
},
[[d, e, f], [a, b, c]],
)
else:
data = await GsBind.delete_uid(qid, ev.bot_id, uid)
@ -54,6 +65,7 @@ async def send_link_uid_msg(bot: Bot, ev: Event):
0: f'删除UID{uid}成功!',
-1: f'该UID{uid}不在已绑定列表中!',
},
[[d2, e, f]],
)

View File

@ -270,6 +270,7 @@ async def draw_pic_with_ring(
mask = mask_pic.resize((size, size))
ring = ring_pic.resize((size, size))
resize_pic = crop_center_img(pic, size, size)
resize_pic = resize_pic.convert('RGBA')
if bg_color:
img_color = Image.new('RGBA', (size, size), bg_color)
img_color.paste(resize_pic, (0, 0), resize_pic)

View File

@ -1,9 +1,17 @@
from typing import Any, Dict, Optional
from typing import Any, Dict, List, Union, Optional
from gsuid_core.bot import Bot
from gsuid_core.message_models import Button
async def send_diff_msg(bot: Bot, code: Any, data: Optional[Dict] = None):
async def send_diff_msg(
bot: Bot,
code: Any,
data: Optional[Dict] = None,
option_list: Optional[
Union[List[str], List[Button], List[List[str]], List[List[Button]]]
] = None,
):
if data is None:
data = {
0: '绑定UID成功!',
@ -13,4 +21,6 @@ async def send_diff_msg(bot: Bot, code: Any, data: Optional[Dict] = None):
}
for retcode in data:
if code == retcode:
return await bot.send(data[retcode])
return await bot.send_option(
data[retcode], option_list, True, '\n'
)