Enka_Genshin_bot/plugins/search.py

30 lines
1.1 KiB
Python
Raw Normal View History

2022-06-04 04:32:48 +00:00
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)
2022-09-02 16:45:18 +00:00
if len(message.command) > 1 and message.command[1].isnumeric():
uid = message.command[1]
2022-06-04 04:32:48 +00:00
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())