Enka_Panel_Bot/plugins/bind.py
2023-01-14 21:59:43 +08:00

27 lines
1.3 KiB
Python

from pyrogram import filters, Client
from pyrogram.types import Message
from defs.bind import check_bind, set_bind, remove_bind
from ci import app, me
uidStart = ["1", "2", "5", "6", "7", "8", "9"]
@app.on_message(filters.command(["bind", f"bind@{me['result']['username']}"]) & filters.private)
async def bind_command(_: Client, message: Message):
if len(message.command) == 1:
if check_bind(message.from_user.id):
return await message.reply("使用 `/info [uid(可选)]` 查询角色缓存状态", quote=True)
else:
return await message.reply("请使用 <code>/bind [uid]</code> 绑定游戏 uid", quote=True)
uid = message.command[1]
if not uid.isdigit():
if uid == "remove":
remove_bind(message.from_user.id)
return await message.reply("已解除绑定", quote=True)
return await message.reply("uid 非数字", quote=True)
elif uid[0] not in uidStart or len(uid) != 9:
return await message.reply("uid 格式错误", quote=True)
set_bind(message.from_user.id, uid)
await message.reply(f"绑定成功,您绑定的游戏 uid 为:{uid}\n\n"
f"请将角色放入展柜,开启显示详细信息后,使用 /refresh 刷新数据。", quote=True)