diff --git a/defs/char_adv.py b/defs/char_adv.py
index 2898240..923cf5e 100644
--- a/defs/char_adv.py
+++ b/defs/char_adv.py
@@ -17,18 +17,22 @@ async def weapon_adv(name):
ws = wb.active
weapon_name = ""
- char_list = []
+ weapons = {}
for c in range(2, 5):
for r in range(2, 300):
if ws.cell(r, c).value:
# if all(i in ws.cell(r,c).value for i in name):
if name in ws.cell(r, c).value:
weapon_name = ws.cell(r, c).value
- char_list.append(ws.cell(2 + ((r - 2) // 5) * 5, 1).value)
+ weapon = weapons.get(weapon_name, [])
+ weapon.append(ws.cell(2 + ((r - 2) // 5) * 5, 1).value)
+ weapons[weapon_name] = weapon
- if char_list:
- im = ','.join(char_list)
- im = im + " 可能会用到【{}】".format(weapon_name)
+ if weapons:
+ im = []
+ for k, v in weapons.items():
+ im.append(f'{"、".join(v)}可能会用到【{k}】')
+ im = '\n'.join(im)
else:
im = " 没有角色能使用【{}】".format(weapon_name if weapon_name else name)
return im
diff --git a/plugins/mys2.py b/plugins/mys2.py
index a6c2704..8aaa3f4 100644
--- a/plugins/mys2.py
+++ b/plugins/mys2.py
@@ -3,10 +3,12 @@ import random
import re
import sqlite3
import traceback
+from genshin import ChineseClient
+
from typing import Union
-from pyrogram import Client
-from pyrogram.types import Message
+from pyrogram import Client, ContinuePropagation, filters
+from pyrogram.types import Message, KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove
from defs.db import deal_ck, selectDB, OpenPush, CheckDB, connectDB, deletecache
from defs.event import generate_event
@@ -19,13 +21,56 @@ from defs.spiral_abyss import draw_abyss_pic, draw_abyss0_pic
from defs.spiral_abyss_text import get_user_abyss
SUPERUSERS = [admin_id]
-
+Cookie_Right_Text = """
+Cookie 有效,请在 30 秒内选择您要绑定的账号:
+"""
+Bind_Right_Text = """
+账号绑定成功,欢迎使用!
+"""
+No_Account_Text = """
+暂无账号信息,请先前往 APP 绑定账号!
+"""
def is_chinese(x: Union[int, str]) -> bool:
"""Recognizes whether the server/uid is chinese."""
return str(x).startswith(("1", "2", "5"))
+async def choose_account(message: Message, results: list,
+ client: Union[ChineseClient] = None):
+ # 选择账号
+ if results:
+ keyboard = []
+ data = {}
+ for i in results:
+ data[str(i.uid)] = i
+ keyboard.append(KeyboardButton(text=f"{i.uid} - {i.nickname} - lv.{i.level}"))
+ msg = await message.reply(Cookie_Right_Text,
+ reply_to_message_id=message.message_id,
+ reply_markup=ReplyKeyboardMarkup([keyboard]))
+ try:
+ ask = await app.listen(message.from_user.id, filters=filters.text, timeout=30) # noqa
+ except asyncio.TimeoutError:
+ await msg.delete()
+ await message.reply("您的操作超时,请重试。", reply_markup=ReplyKeyboardRemove())
+ raise ContinuePropagation
+ except Exception as e:
+ await msg.delete()
+ await message.reply(f"出现错误:{e}", reply_markup=ReplyKeyboardRemove())
+ raise ContinuePropagation
+ try:
+ data = data[ask.text.split(" - ")[0]]
+ except (AttributeError, IndexError, KeyError):
+ await ask.reply("您的操作错误,请重试。", quote=True)
+ raise ContinuePropagation
+ except Exception as e:
+ await ask.reply_text(f"出现错误:{e}", quote=True)
+ raise ContinuePropagation
+ # 写入数据
+ await connectDB(message.from_user.id, data.uid)
+ await connectDB(message.from_user.id, None, client.hoyolab_uid)
+
+
async def mys2_msg(client: Client, message: Message):
text = message.text.replace("米游社", "")
userid = message.from_user.id
@@ -36,13 +81,19 @@ async def mys2_msg(client: Client, message: Message):
return await message.reply_text("获取 Cookie 请参考:[link](https://github.com/Womsxd/AutoMihoyoBBS/"
"#%E8%8E%B7%E5%8F%96%E7%B1%B3%E6%B8%B8%E7%A4%BEcookie)", quote=True)
await deal_ck(mes, userid)
- await message.reply(f'添加Cookies成功!\n'
+ # 开始绑定 uid
+ client_ = ChineseClient()
+ client_.set_cookies(mes)
+ results = await client_.genshin_accounts()
+ await client_.close()
+ await choose_account(message, results, client_)
+ await message.reply(f'=============
\n'
+ f'添加Cookies成功!\n'
f'Cookies属于个人重要信息,如果你是在不知情的情况下添加,'
f'请马上修改米游社账户密码,保护个人隐私!\n'
- f'=============
\n'
- f'如果需要【开启自动签到】和【开启推送】还需要使用命令 '
- f'米游社绑定uid
绑定你的uid。\n'
- f'例如:米游社绑定uid123456789
。')
+ f'=============
', reply_markup=ReplyKeyboardRemove(), quote=True)
+ except ContinuePropagation:
+ raise ContinuePropagation
except Exception as e:
traceback.print_exc()
await message.reply(f'校验失败!请输入正确的Cookies!获取 Cookie 请参考:'
diff --git a/plugins/start.py b/plugins/start.py
index 81aab12..5ed90be 100644
--- a/plugins/start.py
+++ b/plugins/start.py
@@ -4,7 +4,7 @@ from pyrogram.types import Message, CallbackQuery, InlineKeyboardMarkup, InlineK
ReplyKeyboardRemove
HELP_MSG_PRE = 'PaimonBot ' \
- '0.4.4beta By Xtao-Labs\n\n' \
+ '0.4.5beta By Xtao-Labs\n\n' \
'🔅 以下是小派蒙我学会了的功能(部分):\n'
HELP_MSG = """① [武器/今日武器] 查看今日武器材料和武器
② [天赋/今日天赋] 查看今日天赋材料和角色
diff --git a/requirements.txt b/requirements.txt
index 55d2be1..005b496 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -16,3 +16,4 @@ numpy
sqlitedict
openpyxl>=3.0.9
pydantic
+genshin