Enka_Panel_Bot/plugins/search.py
2022-09-03 22:50:36 +08:00

30 lines
1.1 KiB
Python

from os import sep
from pyrogram import filters, Client
from pyrogram.types import Message
from defs.bind import check_bind, get_bind_uid
from ci import app, me
from defs.player import Player
@app.on_message(filters.command(["search", f"search@{me['result']['username']}"]))
async def search_command(_: Client, message: Message):
if message.sender_chat or not message.from_user:
return
uid = None
if check_bind(message.from_user.id):
uid = get_bind_uid(message.from_user.id)
if len(message.command) > 1 and message.command[1].isnumeric():
uid = message.command[1]
if not uid:
return await message.reply("请使用 /search [uid] 或 /bind [uid] 绑定账号后搜索", quote=True)
data = Player(uid)
data.restore()
if not data.all_char:
return await message.reply("没有可展示的角色,可能是数据未刷新", quote=True)
await message.reply_photo(f"resources{sep}Kitsune.png",
caption=f"请选择 {data.name} 的一个角色:",
quote=True,
reply_markup=data.gen_keyboard())