fix genshin

This commit is contained in:
HibiKier 2021-12-26 22:14:01 +08:00
parent 4a8122829e
commit 5e5168f804
8 changed files with 12 additions and 7 deletions

View File

@ -210,6 +210,11 @@ python bot.py
## 更新 ## 更新
### 2021/12/26
* 修复群词条问题 空格 会被录入导致不断回复
* 修复米游社app替换api导致无法正常查询
### 2021/12/24 ### 2021/12/24
* 支持国际疫情数据查询 [@pull/99](https://github.com/HibiKier/zhenxun_bot/pull/99) * 支持国际疫情数据查询 [@pull/99](https://github.com/HibiKier/zhenxun_bot/pull/99)

View File

@ -16,7 +16,7 @@ usage
原神绑定uid [uid] 原神绑定uid [uid]
原神绑定米游社id [mys_id] 原神绑定米游社id [mys_id]
原神绑定cookie [cookie] # 该绑定请私聊 原神绑定cookie [cookie] # 该绑定请私聊
原神解绑 [uid] 原神解绑
示例原神绑定uid 92342233 示例原神绑定uid 92342233
如果不明白怎么获取cookie请输入原神绑定cookie 如果不明白怎么获取cookie请输入原神绑定cookie
""".strip() """.strip()
@ -63,7 +63,7 @@ async def _(bot: Bot, event: MessageEvent, state: T_State):
else: else:
if not msg: if not msg:
await bind.finish( await bind.finish(
"私聊发送!!\n打开https://bbs.mihoyo.com/ys/登录后按F12点击控制台输入document.cookie复制输出的内容即可" "私聊发送!!\n打开https://bbs.mihoyo.com/ys/\n登录后按F12点击控制台输入document.cookie复制输出的内容即可"
) )
if isinstance(event, GroupMessageEvent): if isinstance(event, GroupMessageEvent):
await bind.finish("请立即撤回你的消息并私聊发送!") await bind.finish("请立即撤回你的消息并私聊发送!")

View File

@ -111,10 +111,8 @@ class Genshin(db.Model):
:param flag必须使用自己的cookie :param flag必须使用自己的cookie
""" """
cookie = await cls._get_user_data(None, uid, "cookie") cookie = await cls._get_user_data(None, uid, "cookie")
print(uid, cookie)
if not cookie and not flag: if not cookie and not flag:
cookie = await cls.get_query_cookie(uid) cookie = await cls.get_query_cookie(uid)
print(uid, cookie)
return cookie return cookie
@classmethod @classmethod

View File

@ -55,7 +55,7 @@ async def get_user_memo(user_id: int, uid: int, uname: str) -> Optional[Union[st
async def get_memo(uid: str, server_id: str) -> "Union[str, dict], int": async def get_memo(uid: str, server_id: str) -> "Union[str, dict], int":
try: try:
req = await AsyncHttpx.get( req = await AsyncHttpx.get(
url=f"https://api-takumi.mihoyo.com/game_record/app/genshin/api/dailyNote?server={server_id}&role_id={uid}", url=f"https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/dailyNote?server={server_id}&role_id={uid}",
headers={ headers={
"DS": get_ds(f"role_id={uid}&server={server_id}"), "DS": get_ds(f"role_id={uid}&server={server_id}"),
"x-rpc-app_version": Config.get_config("genshin", "mhyVersion"), "x-rpc-app_version": Config.get_config("genshin", "mhyVersion"),

View File

@ -99,7 +99,7 @@ b=body q=query
async def get_info(uid_: str, server_id: str) -> "Optional[Union[dict, str]], int": async def get_info(uid_: str, server_id: str) -> "Optional[Union[dict, str]], int":
try: try:
req = await AsyncHttpx.get( req = await AsyncHttpx.get(
url=f"https://api-takumi.mihoyo.com/game_record/app/genshin/api/index?server={server_id}&role_id={uid_}", url=f"https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/index?server={server_id}&role_id={uid_}",
headers={ headers={
"Accept": "application/json, text/plain, */*", "Accept": "application/json, text/plain, */*",
"DS": get_ds(f"role_id={uid_}&server={server_id}"), "DS": get_ds(f"role_id={uid_}&server={server_id}"),

View File

@ -209,3 +209,4 @@ class WordBank(db.Model):
if q: if q:
return [(x.answer, x.format.split("<format>")[:-1]) for x in q] return [(x.answer, x.format.split("<format>")[:-1]) for x in q]
return False return False

View File

@ -63,6 +63,8 @@ async def _(bot: Bot, event: GroupMessageEvent, state: T_State):
if not r: if not r:
await add_word.finish("未检测到词条问题...") await add_word.finish("未检测到词条问题...")
problem = r.group(1).strip() problem = r.group(1).strip()
if not problem:
await add_word.finish("未检测到词条问题...")
answer = msg.split('', maxsplit=1)[-1] answer = msg.split('', maxsplit=1)[-1]
if not answer: if not answer:
await add_word.finish("未检测到词条回答...") await add_word.finish("未检测到词条回答...")

View File

@ -6,7 +6,6 @@
"utils", "utils",
"services", "services",
"configs/utils", "configs/utils",
"bot.py"
], ],
"add_file": ["resources/img/genshin/genshin_card", "resources/img/genshin/genshin_memo"], "add_file": ["resources/img/genshin/genshin_card", "resources/img/genshin/genshin_memo"],
"delete_file": [] "delete_file": []