CMHopeSunshine / LittlePaimon

小派蒙!基于Nonebot2的原神机器人,包括但不限于UID面板查询、抽卡记录分析、游戏攻略图鉴、实时便签、原石札记、群聊学习、群管等功能。/ LittlePamon! Genshin Impact multifunctional bot based on Nonebot2.
https://docs.paimon.cherishmoon.top
GNU Affero General Public License v3.0
1.15k stars 127 forks source link

默认ck问题 #8

Closed dozen6 closed 2 years ago

dozen6 commented 2 years ago

机器人默认从第三个ck开始添加一号和二号都是空的 导致前面两个一直调用失败然后延长返回时间

MingxuanGame commented 2 years ago

应该是这两部分的细节没处理好 1.模板写入文件,而不是使用注释提醒或者提示用户修改 hoshino/modules/Genshin_Paimon/util.py变量user_cookies_example

user_cookies_example = {
    "通用": [
        {
            "cookie": "",
            "no": 1
        },
        {
            "cookie": "",
            "no": 2
        }
    ],
    "私人":{}

}

2.ck校验未对必要值和空字符进行验证 hoshino/modules/Genshin_Paimon/util.py函数check_cookie

async def check_cookie(cookie):
    url = 'https://bbs-api.mihoyo.com/user/wapi/getUserFullInfo?gids=2'
    headers ={
        'DS': get_ds(),
        'Origin': 'https://webstatic.mihoyo.com',
        'Cookie': cookie,
        'x-rpc-app_version': "2.11.1",
        'x-rpc-client_type': '5',
        'Referer': 'https://webstatic.mihoyo.com/'
    }
    res = await aiorequests.get(url=url,headers=headers)
    res = await res.json()
    if res['retcode'] != 0:
        return False
    else:
        return True
CMHopeSunshine commented 2 years ago

已知晓,打算过会重做一下cookie方案

CMHopeSunshine commented 2 years ago

重做了cookie存储方案,改用sqlite存储,之前的有效cookie会自动迁移到数据库,不过注意备份一下,不确保没有BUG...