Ljzd-PRO / nonebot-plugin-mystool

QQ聊天、频道机器人插件 | 米游社工具-每日米游币任务、游戏签到、商品兑换、免抓包登录、原神崩铁便笺提醒
https://pypi.org/project/nonebot-plugin-mystool
MIT License
392 stars 47 forks source link

报错 #309

Closed beiji-O-o closed 1 week ago

beiji-O-o commented 1 month ago
image
dontdot commented 1 month ago

好像要调下日志级别,debug日志一个没看到

dontdot commented 1 month ago

好像要调下日志级别,debug日志一个没看到

去data那看下日志文件

beiji-O-o commented 1 month ago

好像要调下日志级别,debug日志一个没看到

去data那看下日志文件

data在哪里

dontdot commented 1 month ago

跟配置文件一个文件夹的那个日志文件

beiji-O-o commented 1 month ago

跟配置文件一个文件夹的那个日志文件

image 这个吗

dontdot commented 1 month ago

beiji-O-o commented 1 month ago

image
beiji-O-o commented 1 month ago

image

跟控制台里的一样的。。 需要整个日志文件吗,需要的话给我个邮箱。

dontdot commented 1 month ago

知道什么原因了 参考 #195 resultid是查询凭证,还要过一次请求才能得到验证结果

beiji-O-o commented 1 month ago

知道什么原因了 参考 #195 resultid是查询凭证,还要过一次请求才能得到验证结果

那咋弄。。

dontdot commented 1 month ago

再套一次请求咯,大概是这样 image

    try:
        async for attempt in get_async_retry(retry):
            with attempt:
                async with httpx.AsyncClient() as client:
                    res = await client.post(
                        geetest_url,
                        params=params,
                        json=content,
                        timeout=60
                    )
                geetest_data = res.json()
                content_v2 = {'appkey': content['appkey']}
                content_v2.update(geetest_data['resultid'])
                async with httpx.AsyncClient() as client:
                    res = await client.post(
                        'http://api.ttocr.com/api/results',
                        json=content_v2,
                        timeout=60
                    )
                geetest_data_v2 = res.json()
                logger.debug(f"{plugin_config.preference.log_head}人机验证结果:{geetest_data_v2}")
                validate = geetest_data_v2['data']['validate']
                seccode = geetest_data_v2['data'].get('seccode') or f"{validate}|jordan"
                return GeetestResult(validate=validate, seccode=seccode)
    except tenacity.RetryError:
        logger.exception(f"{plugin_config.preference.log_head}获取人机验证validate失败")
beiji-O-o commented 1 month ago

再套一次请求咯,大概是这样 image

    try:
        async for attempt in get_async_retry(retry):
            with attempt:
                async with httpx.AsyncClient() as client:
                    res = await client.post(
                        geetest_url,
                        params=params,
                        json=content,
                        timeout=60
                    )
                geetest_data = res.json()
                content_v2 = {'appkey': content['appkey']}
                content_v2.update(geetest_data['resultid'])
                async with httpx.AsyncClient() as client:
                    res = await client.post(
                        'http://api.ttocr.com/api/results',
                        json=content_v2,
                        timeout=60
                    )
                geetest_data_v2 = res.json()
                logger.debug(f"{plugin_config.preference.log_head}人机验证结果:{geetest_data_v2}")
                validate = geetest_data_v2['data']['validate']
                seccode = geetest_data_v2['data'].get('seccode') or f"{validate}|jordan"
                return GeetestResult(validate=validate, seccode=seccode)
    except tenacity.RetryError:
        logger.exception(f"{plugin_config.preference.log_head}获取人机验证validate失败")
image image
dontdot commented 1 month ago

content_v2.update(geetest_data['resultid'])

content_v2['resultid'] = (geetest_data['resultid'])

beiji-O-o commented 1 month ago

content_v2['resultid'] = (geetest_data['resultid'])

image image
dontdot commented 1 month ago

image 打印出来看看返回什么

beiji-O-o commented 1 month ago

image 打印出来看看返回什么

image
dontdot commented 1 month ago
    try:
        async for attempt in get_async_retry(retry):
            with attempt:
                async with httpx.AsyncClient() as client:
                    res = await client.post(
                        geetest_url,
                        params=params,
                        json=content,
                        timeout=60
                    )
                geetest_data = res.json()
                logger.debug(f"{plugin_config.preference.log_head}验证初步提交:{geetest_data}")
                content_v2 = {'appkey': content['appkey']}
                content_v2['resultid'] = (geetest_data['resultid'])
                logger.info('等待识别时间中')
                time.sleep(6) 
                async with httpx.AsyncClient() as client:
                    res = await client.post(
                        'http://api.ttocr.com/api/results',
                        json=content_v2,
                        timeout=60
                    )
                geetest_data_v2 = res.json()
                logger.debug(f"{plugin_config.preference.log_head}人机验证结果:{geetest_data_v2}")
                validate = geetest_data_v2['data']['validate']
                seccode = geetest_data_v2['data'].get('seccode') or f"{validate}|jordan"
                return GeetestResult(validate=validate, seccode=seccode)
    except tenacity.RetryError:
        logger.exception(f"{plugin_config.preference.log_head}获取人机验证validate失败")

我自己试了,这个可用

beiji-O-o commented 1 month ago
    try:
        async for attempt in get_async_retry(retry):
            with attempt:
                async with httpx.AsyncClient() as client:
                    res = await client.post(
                        geetest_url,
                        params=params,
                        json=content,
                        timeout=60
                    )
                geetest_data = res.json()
                logger.debug(f"{plugin_config.preference.log_head}验证初步提交:{geetest_data}")
                content_v2 = {'appkey': content['appkey']}
                content_v2['resultid'] = (geetest_data['resultid'])
                logger.info('等待识别时间中')
                time.sleep(6) 
                async with httpx.AsyncClient() as client:
                    res = await client.post(
                        'http://api.ttocr.com/api/results',
                        json=content_v2,
                        timeout=60
                    )
                geetest_data_v2 = res.json()
                logger.debug(f"{plugin_config.preference.log_head}人机验证结果:{geetest_data_v2}")
                validate = geetest_data_v2['data']['validate']
                seccode = geetest_data_v2['data'].get('seccode') or f"{validate}|jordan"
                return GeetestResult(validate=validate, seccode=seccode)
    except tenacity.RetryError:
        logger.exception(f"{plugin_config.preference.log_head}获取人机验证validate失败")

我自己试了,这个可用

image image

还是第一次可以(部分完成不了)后面全部报错

dontdot commented 1 month ago

截图log文件里的,这图看不到debug级别日志

beiji-O-o commented 1 month ago

截图log文件里的,这图看不到debug级别日志

image
dontdot commented 1 month ago

https://github.com/Ljzd-PRO/nonebot-plugin-mystool/blob/505b184af0a52c765abb73a14811a520eaf2e0e2/src/nonebot_plugin_mystool/api/myb_missions_api.py#L298 在这下面添加这个,查看返回内容

logger.debug(f"检查点赞返回:{api_result}")

点赞成功的返回是这样的检查点赞返回:content={'retcode': 0, 'message': 'OK', 'data': {}} data={} message='OK' retcode=0

beiji-O-o commented 1 month ago
logger.debug(f"检查点赞返回:{api_result}")

突然又能用了不会报错了。。

beiji-O-o commented 1 month ago

https://github.com/Ljzd-PRO/nonebot-plugin-mystool/blob/505b184af0a52c765abb73a14811a520eaf2e0e2/src/nonebot_plugin_mystool/api/myb_missions_api.py#L298

在这下面添加这个,查看返回内容

logger.debug(f"检查点赞返回:{api_result}")

点赞成功的返回是这样的检查点赞返回:content={'retcode': 0, 'message': 'OK', 'data': {}} data={} message='OK' retcode=0

image

这个早上使用/任务*的时候报错,我刚才再试又不会报错了,昨天也是这样

beiji-O-o commented 1 month ago

现在又出现了 /任务* 卡在某一个账号不能继续的bug了...

dontdot commented 1 month ago

没遇到过这种情况,有可能是账号的问题

dontdot commented 1 month ago

接口可能返回1034错误 不清楚是不是这个原因 可以去试下根据米游币签到验证的代码也给点赞套上一层验证 或者试试换个ua?

beiji-O-o commented 1 month ago

接口可能返回1034错误

不清楚是不是这个原因

可以去试下根据米游币签到验证的代码也给点赞套上一层验证

或者试试换个ua?

ua是什么

dontdot commented 1 month ago

User-Agent

beiji-O-o commented 1 month ago

User-Agent

这个要咋换 随便改几个字吗

Ljzd-PRO commented 1 month ago

User-Agent

这个要咋换 随便改几个字吗

有个方法是把那种查看当前客户端UA的网站链接转换为二维码,然后米游社App扫描

duki-web commented 1 month ago

我发现每次当我重新安装nonebot-plugin-mystool,并重新登陆账号,就一定不会弹验证码

beiji-O-o commented 1 month ago

User-Agent

ua改哪里啊

dontdot commented 1 month ago

User-Agent

这个要咋换 随便改几个字吗

有个方法是把那种查看当前客户端UA的网站链接转换为二维码,然后米游社App扫描

怎么米游币用的是USER_AGENT_ANDROID_OTHER而不是USER_AGENT_ANDROID

duki-web commented 1 month ago

06-15 11:30:00 [INFO] nonebot_plugin_mystool | 开始执行每日自动任务 06-15 11:30:28 [WARNING] nonebot_plugin_mystool | 游戏签到 - 用户 7xxxxxx1 可能被人机验证阻拦 06-15 11:30:28 [DEBUG] nonebot_plugin_mystool | 网络请求返回: {"retcode":0,"message":"OK","data":{"code":"","risk_code":5001,"gt":"afa69b855e321950b027ebab65f86ce8","challenge":"cf7202b0cbc1f94a278c5e2d032fb926","success":1,"is_risk":true}} 06-15 11:30:28 [DEBUG] nonebot_plugin_mystool | get_validate: {'geetest_url': 'http://api.ttocr.com/api/recognize', 'params': {'gt': 'afa69b855e321950b027ebab65f86ce8', 'challenge': 'cf7202b0cbc1f94a278c5e2d032fb926'}, 'content': {'gt': 'afa69b855e321950b027ebab65f86ce8', 'challenge': 'cf7202b0cbc1f94a278c5e2d032fb926', 'appkey': '6xxxxxxxxxxxxxxxxxx3', 'itemid': 488, 'referer': 'https://act.mihoyo.com/'}} 06-15 11:30:34 [DEBUG] nonebot_plugin_mystool | 验证初步提交:{'status': 4005, 'msg': 'appkey不存在1'} 06-15 11:30:42 [DEBUG] nonebot_plugin_mystool | 验证初步提交:{'status': 4005, 'msg': 'appkey不存在1'} 06-15 11:30:50 [DEBUG] nonebot_plugin_mystool | 验证初步提交:{'status': 4005, 'msg': 'appkey不存在1'} 06-15 11:30:58 [DEBUG] nonebot_plugin_mystool | 验证初步提交:{'status': 4005, 'msg': 'appkey不存在1'} 06-15 11:30:58 [ERROR] nonebot_plugin_mystool | 获取人机验证validate失败 Traceback (most recent call last): File "/root/mikl/.venv/lib/python3.9/site-packages/nonebot_plugin_mystool/utils/common.py", line 276, in get_validate content_v2['resultid'] = (geetest_data['resultid']) KeyError: 'resultid'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "", line 17, in File "/root/mikl/.venv/lib/python3.9/site-packages/nonebot/init.py", line 335, in run get_driver().run(*args, kwargs) File "/root/mikl/.venv/lib/python3.9/site-packages/nonebot/drivers/none.py", line 56, in run loop.run_until_complete(self._serve()) File "/usr/lib/python3.9/asyncio/base_events.py", line 629, in run_until_complete self.run_forever() File "/usr/lib/python3.9/asyncio/base_events.py", line 596, in run_forever self._run_once() File "/usr/lib/python3.9/asyncio/base_events.py", line 1890, in _run_once handle._run() File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run self._context.run(self._callback, self._args) File "/root/mikl/.venv/lib/python3.9/site-packages/apscheduler/executors/base_py3.py", line 30, in run_coroutine_job retval = await job.func(job.args, job.kwargs) File "/root/mikl/.venv/lib/python3.9/site-packages/nonebot_plugin_mystool/command/plan.py", line 752, in daily_schedule await perform_game_sign(user=user, user_ids=user_ids) File "/root/mikl/.venv/lib/python3.9/site-packages/nonebot_plugin_mystool/command/plan.py", line 268, in perform_game_sign geetest_result = await get_validate(user, mmt_data.gt, mmt_data.challenge)

File "/root/mikl/.venv/lib/python3.9/site-packages/nonebot_plugin_mystool/utils/common.py", line 264, in get_validate async for attempt in get_async_retry(retry): File "/root/mikl/.venv/lib/python3.9/site-packages/tenacity/_asyncio.py", line 123, in anext do = await self.iter(retry_state=self._retry_state) File "/root/mikl/.venv/lib/python3.9/site-packages/tenacity/_asyncio.py", line 110, in iter result = await action(retry_state) File "/root/mikl/.venv/lib/python3.9/site-packages/tenacity/_asyncio.py", line 78, in inner return fn(*args, **kwargs) File "/root/mikl/.venv/lib/python3.9/site-packages/tenacity/init.py", line 411, in exc_check raise retry_exc from fut.exception() tenacity.RetryError: RetryError[<Future at 0xffff81e4e3a0 state=finished raised KeyError>] 06-15 11:31:00 [DEBUG] nonebot_plugin_mystool | 检查点赞返回:content={'retcode': 0, 'message': 'OK', 'data': {}} data={} message='OK' retcode=0 06-15 11:31:07 [DEBUG] nonebot_plugin_mystool | 检查点赞返回:content={'retcode': 0, 'message': 'OK', 'data': {}} data={} message='OK' retcode=0 06-15 11:31:15 [WARNING] nonebot_plugin_mystool | 游戏签到 - 用户 7xxxxxx1 可能被人机验证阻拦 06-15 11:31:15 [DEBUG] nonebot_plugin_mystool | 网络请求返回: {"retcode":0,"message":"OK","data":{"code":"","risk_code":5001,"gt":"afa69b855e321950b027ebab65f86ce8","challenge":"130202d7a3549722ee963e745aeae462","success":1,"is_risk":true}} 06-15 11:31:15 [INFO] nonebot_plugin_mystool | 向用户 57xxxxxx19 发送 QQ 频道私信 recipient_id: 57xxxxxx19, source_guild_id: 67xxxxxx19 06-15 11:31:15 [DEBUG] nonebot_plugin_mystool | 检查点赞返回:content={'retcode': 0, 'message': 'OK', 'data': {}} data={} message='OK' retcode=0 06-15 11:31:23 [DEBUG] nonebot_plugin_mystool | 检查点赞返回:content={'retcode': 0, 'message': 'OK', 'data': {}} data={} message='OK' retcode=0 06-15 11:31:36 [DEBUG] nonebot_plugin_mystool | 检查点赞返回:content={'retcode': 0, 'message': 'OK', 'data': {}} data={} message='OK' retcode=0 06-15 11:31:44 [DEBUG] nonebot_plugin_mystool | 检查点赞返回:content={'retcode': 0, 'message': 'OK', 'data': {}} data={} message='OK' retcode=0 06-15 11:31:45 [WARNING] nonebot_plugin_mystool | 游戏签到 - 用户 7xxxxxx1 可能被人机验证阻拦 06-15 11:31:45 [DEBUG] nonebot_plugin_mystool | 网络请求返回: {"retcode":0,"message":"OK","data":{"code":"","risk_code":5001,"gt":"ccc71324fd054bb75dc80f0467319a4f","challenge":"b94e22bd03001c0a2e743b6c30f26580","success":1,"is_risk":true}} 06-15 11:31:45 [DEBUG] nonebot_plugin_mystool | get_validate: {'geetest_url': 'http://api.ttocr.com/api/recognize', 'params': {'gt': 'ccc71324fd054bb75dc80f0467319a4f', 'challenge': 'b94e22bd03001c0a2e743b6c30f26580'}, 'content': {'gt': 'ccc71324fd054bb75dc80f0467319a4f', 'challenge': 'b94e22bd03001c0a2e743b6c30f26580', 'appkey': '6xxxxxxxxxxxxxxxxxx3', 'itemid': 488, 'referer': 'https://act.mihoyo.com/'}} 06-15 11:31:51 [DEBUG] nonebot_plugin_mystool | 验证初步提交:{'status': 4005, 'msg': 'appkey不存在1'} 06-15 11:31:51 [DEBUG] nonebot_plugin_mystool | 检查点赞返回:content={'retcode': 0, 'message': 'OK', 'data': {}} data={} message='OK' retcode=0 06-15 11:31:59 [DEBUG] nonebot_plugin_mystool | 检查点赞返回:content={'retcode': 0, 'message': 'OK', 'data': {}} data={} message='OK' retcode=0 06-15 11:31:59 [DEBUG] nonebot_plugin_mystool | 验证初步提交:{'status': 4005, 'msg': 'appkey不存在1'} 06-15 11:32:07 [DEBUG] nonebot_plugin_mystool | 验证初步提交:{'status': 4005, 'msg': 'appkey不存在1'} 06-15 11:32:12 [DEBUG] nonebot_plugin_mystool | 检查点赞返回:content={'retcode': 0, 'message': 'OK', 'data': {}} data={} message='OK' retcode=0 06-15 11:32:16 [DEBUG] nonebot_plugin_mystool | 验证初步提交:{'status': 4005, 'msg': 'appkey不存在1'} 06-15 11:32:16 [ERROR] nonebot_plugin_mystool | 获取人机验证validate失败 Traceback (most recent call last): File "/root/mikl/.venv/lib/python3.9/site-packages/nonebot_plugin_mystool/utils/common.py", line 276, in get_validate content_v2['resultid'] = (geetest_data['resultid']) KeyError: 'resultid'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "", line 17, in File "/root/mikl/.venv/lib/python3.9/site-packages/nonebot/init.py", line 335, in run get_driver().run(*args, kwargs) File "/root/mikl/.venv/lib/python3.9/site-packages/nonebot/drivers/none.py", line 56, in run loop.run_until_complete(self._serve()) File "/usr/lib/python3.9/asyncio/base_events.py", line 629, in run_until_complete self.run_forever() File "/usr/lib/python3.9/asyncio/base_events.py", line 596, in run_forever self._run_once() File "/usr/lib/python3.9/asyncio/base_events.py", line 1890, in _run_once handle._run() File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run self._context.run(self._callback, self._args) File "/root/mikl/.venv/lib/python3.9/site-packages/apscheduler/executors/base_py3.py", line 30, in run_coroutine_job retval = await job.func(job.args, job.kwargs) File "/root/mikl/.venv/lib/python3.9/site-packages/nonebot_plugin_mystool/command/plan.py", line 752, in daily_schedule await perform_game_sign(user=user, user_ids=user_ids) File "/root/mikl/.venv/lib/python3.9/site-packages/nonebot_plugin_mystool/command/plan.py", line 268, in perform_game_sign geetest_result = await get_validate(user, mmt_data.gt, mmt_data.challenge)

File "/root/mikl/.venv/lib/python3.9/site-packages/nonebot_plugin_mystool/utils/common.py", line 264, in get_validate async for attempt in get_async_retry(retry): File "/root/mikl/.venv/lib/python3.9/site-packages/tenacity/_asyncio.py", line 123, in anext do = await self.iter(retry_state=self._retry_state) File "/root/mikl/.venv/lib/python3.9/site-packages/tenacity/_asyncio.py", line 110, in iter result = await action(retry_state) File "/root/mikl/.venv/lib/python3.9/site-packages/tenacity/_asyncio.py", line 78, in inner return fn(*args, **kwargs) File "/root/mikl/.venv/lib/python3.9/site-packages/tenacity/init.py", line 411, in exc_check raise retry_exc from fut.exception() tenacity.RetryError: RetryError[<Future at 0xffff81ddbe20 state=finished raised KeyError>] 06-15 11:32:20 [DEBUG] nonebot_plugin_mystool | 检查点赞返回:content={'retcode': 0, 'message': 'OK', 'data': {}} data={} message='OK' retcode=0

报错来了 @Joseandluue

dontdot commented 1 month ago

appkey不存在,确认没错吗,贴一下你现在用的这个函数的代码块截图出来https://github.com/Ljzd-PRO/nonebot-plugin-mystool/blob/505b184af0a52c765abb73a14811a520eaf2e0e2/src/nonebot_plugin_mystool/utils/common.py#L235

duki-web commented 1 month ago

appkey不存在,确认没错吗,贴一下你现在用的这个函数的代码块截图出来

https://github.com/Ljzd-PRO/nonebot-plugin-mystool/blob/505b184af0a52c765abb73a14811a520eaf2e0e2/src/nonebot_plugin_mystool/utils/common.py#L235

屏幕截图 2024-06-15 125535

不知道为什么是appkey不存在,同一个appkey在其他项目就可以过

dontdot commented 1 month ago

这样我真不知道哪有问题,appkey不能为空还好说,appkey不存在有可能不是代码的问题

beiji-O-o commented 1 month ago

6444f5d753c64a2cbb44bd32554a6893

你key露出来了。。 还有就是appkey返回为空,在文档里面写了重置一次就可以了

duki-web commented 1 month ago

哪里重置? @beiji-O-o

beiji-O-o commented 1 month ago

哪里重置? @beiji-O-o

打码平台面板有个重置key

beiji-O-o commented 1 month ago

User-Agent

这个要咋换 随便改几个字吗

有个方法是把那种查看当前客户端UA的网站链接转换为二维码,然后米游社App扫描

怎么米游币用的是USER_AGENT_ANDROID_OTHER而不是USER_AGENT_ANDROID

咋弄啊,现在/任务*就卡住报错,/任务就没问题

dontdot commented 1 month ago

我想知道/签到*有报错吗

beiji-O-o commented 1 month ago

我想知道/签到*有报错吗

我试试,我都不知道有这个功能。

beiji-O-o commented 1 month ago

我想知道/签到*有报错吗

/签到 没问题 我让全部人手动/任务后我现在/任务也可以正常过了。。

dontdot commented 1 month ago

我想知道/签到*有报错吗

/签到 没问题 我让全部人手动/任务后我现在/任务也可以正常过了。。

你每天/任务*的时候,报错前谈论区的签到显示成功没?

beiji-O-o commented 1 month ago

我想知道/签到*有报错吗

/签到 没问题 我让全部人手动/任务后我现在/任务也可以正常过了。。

你每天/任务*的时候,报错前谈论区的签到显示成功没?

我明天看看 我现在已经/任务*了

dontdot commented 1 month ago

我明天看看 我现在已经/任务*了

今天/任务*没有报错吗,有的话可以去日志里看到

beiji-O-o commented 1 month ago

我明天看看 我现在已经/任务*了

今天/任务*没有报错吗,有的话可以去日志里看到

评论区的打卡都打了,没问题

dontdot commented 1 month ago

唉,我试不出来这个报错 https://github.com/Ljzd-PRO/nonebot-plugin-mystool/blob/505b184af0a52c765abb73a14811a520eaf2e0e2/src/nonebot_plugin_mystool/api/myb_missions_api.py#L288 你试试在这行下面加上这个吧,看看改成这个ua有没有效果

headers["User-Agent"] = plugin_env.device_config.USER_AGENT_ANDROID
beiji-O-o commented 1 month ago

唉,我试不出来这个报错

https://github.com/Ljzd-PRO/nonebot-plugin-mystool/blob/505b184af0a52c765abb73a14811a520eaf2e0e2/src/nonebot_plugin_mystool/api/myb_missions_api.py#L288

你试试在这行下面加上这个吧,看看改成这个ua有没有效果

headers["User-Agent"] = plugin_env.device_config.USER_AGENT_ANDROID

image image