Ljzd-PRO / nonebot-plugin-mystool

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

星穹铁道的便笺 #140

Closed dontdot closed 1 year ago

dontdot commented 1 year ago

后续有计划做星穹铁道的便笺吗?我尝试自己去添加,结果返回的内容是

07-17 15:38:25 [DEBUG] nonebot_plugin_mystool | 网络请求返回: {"data":null,"message":"invalid request","retcode":-10001}

我添加了

URL_STARRAIL_STATUS_BBS = "https://api-takumi-record.mihoyo.com/game_record/app/hkrpg/api/note"
URL_STARRAIL_STATUS_WIDGET = "https://api-takumi-record.mihoyo.com/game_record/app/hkrpg/aapi/widget"

async def StarRail_board(account: UserAccount) -> Tuple[
    Union[BaseApiStatus, StarRailBoardStatus], Optional[StarRailBoard]]:
    """
    获取星铁实时便笺

    :param account: 用户账户数据
    """
    game_record_status, records = await get_game_record(account)
    if not game_record_status:
        return game_record_status, None
    game_list_status, game_list = await get_game_list()
    if not game_list_status:
        return game_list_status, None
    game_filter = filter(lambda x: x.en_name == 'sr', game_list)
    game_info = next(game_filter, None)
    if not game_info:
        return StarRailBoardStatus(no_starrail_account=True), None
    else:
        game_id = game_info.id
    flag = True
    for record in records:
        if record.game_id == game_id:
            try:
                flag = False
                params = {"role_id": record.game_role_id, "server": record.region}
                print("params:",params)
                url = f"{URL_STARRAIL_STATUS_BBS}?{urlencode(params)}"
                print(url)
                headers = HEADERS_STARRAIL_STATUS_BBS.copy()
                headers["x-rpc-device_id"] = account.device_id_android
                async for attempt in get_async_retry(False):
                    with attempt:
                        headers["DS"] = generate_ds(
                            params={"role_id": record.game_role_id, "server": record.region})
                        print(headers)
                        async with httpx.AsyncClient() as client:
                            res = await client.get(url, headers=headers,
                                                   cookies=account.cookies.dict(v2_stoken=True, cookie_type=True),
                                                   timeout=_conf.preference.timeout)
                        api_result = ApiResultHandler(res.json())
                        print("第一次:",api_result)
                        if api_result.login_expired:
                            logger.info(
                                f"星铁实时便笺: 用户 {account.bbs_uid} 登录失效")
                            logger.debug(f"网络请求返回: {res.text}")
                            return StarRailBoardStatus(login_expired=True), None

                        if api_result.invalid_ds:
                            logger.info(
                                f"星铁实时便笺: 用户 {account.bbs_uid} DS 校验失败")
                            logger.debug(f"网络请求返回: {res.text}")
                        if api_result.retcode == 1034:
                            logger.info(
                                f"星铁实时便笺: 用户 {account.bbs_uid} 可能被验证码阻拦")
                            logger.debug(f"网络请求返回: {res.text}")
                        if api_result.invalid_ds or api_result.retcode == 1034:
                            headers["DS"] = generate_ds()
                            headers["x-rpc-device_id"] = account.device_id_ios
                            async with httpx.AsyncClient() as client:
                                res = await client.get(
                                    URL_STARRAIL_STATUS_WIDGET,
                                    headers=headers,
                                    cookies=account.cookies.dict(v2_stoken=True, cookie_type=True),
                                    timeout=_conf.preference.timeout
                                )
                            print("请求返回:",res)
                            api_result = ApiResultHandler(res.json())
                            print("第二次:",api_result)
                            return StarRailBoardStatus(success=True), \
                                StarRailBoard.parse_obj(api_result.data)
                        return StarRailBoardStatus(success=True), StarRailBoard.parse_obj(api_result.data)
            except tenacity.RetryError as e:
                if is_incorrect_return(e):
                    logger.exception(f"星铁实时便笺: 服务器没有正确返回")
                    logger.debug(f"网络请求返回: {res.text}")
                    return StarRailBoardStatus(incorrect_return=True), None
                else:
                    logger.exception(f"星铁实时便笺: 请求失败")
                    return StarRailBoardStatus(network_error=True), None
    if flag:
        return StarRailBoardStatus(no_starrail_account=True), None

game_list和game_records都成功返回内容,但是倒在了这里

async with httpx.AsyncClient() as client:
                            res = await client.get(url, headers=headers,
                                                   cookies=account.cookies.dict(v2_stoken=True, cookie_type=True),
                                                   timeout=_conf.preference.timeout)
                        api_result = ApiResultHandler(res.json())

下面是终端上的错误信息

07-17 15:38:20 [SUCCESS] nonebot | OneBot V11 3451066253 | [message.private.friend]: Message -892711309 from aaaaaaaa '/便笺sr'
07-17 15:38:20 [DEBUG] nonebot | Checking for matchers in priority 1...
07-17 15:38:20 [DEBUG] nonebot | Checking for matchers in priority 4...
07-17 15:38:20 [DEBUG] nonebot | Checking for matchers in priority 5...
07-17 15:38:20 [INFO] nonebot | Event will be handled by Matcher(type='message', module=nonebot_plugin_mystool.plan)
07-17 15:38:20 [DEBUG] nonebot | Running Matcher(type='message', module=nonebot_plugin_mystool.plan)
07-17 15:38:20 [TRACE] nonebot | Matcher(type='message', module=nonebot_plugin_mystool.plan) run with incoming args: bot=Bot(type='OneBot V11', self_id='3451066253'), event=PrivateMessageEvent(time=1689579500, self_id=3451066253, post_type='message', sub_type='friend', user_id=aaaaaaaa, message_type='private', message_id=-892711309, message=[MessageSegment(type='text', data={'text': '/便笺sr'})], original_message=[MessageSegment(type='text', data={'text': '/便笺sr'})], raw_message='/便笺sr', font=0, sender=Sender(user_id=aaaaaaaa, nickname='哥', sex='unknown', age=0, card=None, area=None, level=None, role=None, title=None), to_me=True, reply=None, target_id=3451066253), state={'_prefix': {'command': ('便笺sr',), 'raw_command': '/便笺sr', 'command_arg': [], 'command_start': '/', 'command_whitespace': None}}
07-17 15:38:20 [DEBUG] nonebot | Running handler Dependent(call=_)
---params: {'role_id': 'bbbbbbb', 'server': 'prod_gf_cn'}
---https://api-takumi-record.mihoyo.com/game_record/app/hkrpg/api/note?role_id=bbbbbbb&server=prod_gf_cn
---{'DS': '1689579501,193865,3b4a00e9fef2b03514d8e315646212d6', 'x-rpc-device_id': 'F9235676-FBF4-46E5-BB9E-A9330E0FDC88', 'Accept': 'application/json,text/plain,*/*', 'Origin': 'https://webstatic.mihoyo.com', 'User-agent': 'Mozilla/5.0 (Linux; Android 11; MI 8 SE Build/RQ3A.211001.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/104.0.5112.97 Mobile Safari/537.36 miHoYoBBS/2.36.1', 'Referer': 'https://webstatic.mihoyo.com/', 'x-rpc-app_version': '2.28.1', 'x-rpc-channel': 'ys', 'X-Requested-With': 'com.mihoyo.hyperion', 'x-rpc-client_type': '5'}
---第一次: content={'data': None, 'message': '', 'retcode': 1034} data=None message=None retcode=1034
07-17 15:38:22 [INFO] nonebot_plugin_mystool | 星铁实时便笺: 用户 76454149 可能被验证码阻拦
07-17 15:38:22 [DEBUG] nonebot_plugin_mystool | 网络请求返回: {"data":null,"message":"","retcode":1034}
---请求返回: <Response [200 OK]>
---第二次: content={'data': None, 'message': 'invalid request', 'retcode': -10001} data=None message='invalid request' retcode=-10001
07-17 15:38:24 [ERROR] nonebot_plugin_mystool | 星铁实时便笺: 服务器没有正确返回
Traceback (most recent call last):
  File "pydantic\main.py", line 522, in pydantic.main.BaseModel.parse_obj
    obj = dict(obj)
TypeError: 'NoneType' object is not iterable

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

Traceback (most recent call last):
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\site-packages\nonebot_plugin_mystool\simple_api.py", line 1475, in StarRail_board
    StarRailBoard.parse_obj(api_result.data)
  File "pydantic\main.py", line 525, in pydantic.main.BaseModel.parse_obj
    raise ValidationError([ErrorWrapper(exc, loc=ROOT_KEY)], cls) from e
pydantic.error_wrappers.ValidationError: 1 validation error for StarRailBoard
__root__
  StarRailBoard expected dict not NoneType (type=type_error)

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

Traceback (most recent call last):
  File "<string>", line 17, in <module>
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\site-packages\nonebot\__init__.py", line 309, in run
    get_driver().run(*args, **kwargs)
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\site-packages\nonebot\drivers\fastapi.py", line 198, in run
    uvicorn.run(
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\site-packages\uvicorn\main.py", line 578, in run
    server.run()
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\site-packages\uvicorn\server.py", line 61, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\asyncio\base_events.py", line 640, in run_until_complete
    self.run_forever()
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\asyncio\windows_events.py", line 321, in run_forever
    super().run_forever()
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\asyncio\base_events.py", line 607, in run_forever
    self._run_once()
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\asyncio\base_events.py", line 1922, in _run_once
    handle._run()
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\site-packages\nonebot\message.py", line 467, in check_and_run_matcher
    await _run_matcher(
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\site-packages\nonebot\message.py", line 419, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\site-packages\nonebot\internal\matcher\matcher.py", line 753, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\site-packages\nonebot\internal\matcher\matcher.py", line 728, in simple_run
    await handler(
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\site-packages\nonebot\dependencies\__init__.py", line 108, in __call__
    return await cast(Callable[..., Awaitable[R]], self.call)(**values)
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\site-packages\nonebot_plugin_mystool\plan.py", line 102, in _
    await resin_check_sr(bot=bot, qq=event.user_id, is_auto=False, group_event=event)
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\site-packages\nonebot_plugin_mystool\plan.py", line 462, in resin_check_sr
    starrail_board_status, board = await StarRail_board(account)
> File "C:\ProgramData\anaconda3\envs\mhy\Lib\site-packages\nonebot_plugin_mystool\simple_api.py", line 1436, in StarRail_board
    async for attempt in get_async_retry(False):
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\site-packages\tenacity\_asyncio.py", line 71, in __anext__
    do = self.iter(retry_state=self._retry_state)
  File "C:\ProgramData\anaconda3\envs\mhy\Lib\site-packages\tenacity\__init__.py", line 326, in iter
    raise retry_exc from fut.exception()
tenacity.RetryError: RetryError[<Future at 0x1f75acef690 state=finished raised ValidationError>]
07-17 15:38:25 [DEBUG] nonebot_plugin_mystool | 网络请求返回: {"data":null,"message":"invalid request","retcode":-10001}
07-17 15:38:25 [INFO] nonebot_plugin_mystool | success=False network_error=False incorrect_return=True login_expired=False need_verify=False invalid_ds=False no_starrail_account=False
07-17 15:38:25 [DEBUG] nonebot | OneBot V11 | Calling API send_private_msg
07-17 15:38:26 [INFO] nonebot | Matcher(type='message', module=nonebot_plugin_mystool.plan) running complete
07-17 15:38:26 [DEBUG] nonebot | Stop event propagation
07-17 15:38:26 [DEBUG] nonebot | Checking for matchers completed
RemiDre commented 1 year ago

我这里瞎改跑通了 你试下 /game_record/app/hkrpg/api/note 玩家信息页这里内容不全,直接换成/game_record/app/hkrpg/aapi/widget小组件了

URL_STARRAIL_STATUS_WIDGET = "https://api-takumi-record.mihoyo.com/game_record/app/hkrpg/aapi/widget"

HEADERS_STARRAIL_STATUS_WIDGET = {
    "Accept": "*/*",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept-Language": "zh-CN,zh-Hans;q=0.9",
    "User-Agent": _conf.device_config.USER_AGENT_WIDGET,

    # "DS": None,
    "Referer": "https://app.mihoyo.com",
    "x-rpc-app_version": _conf.device_config.X_RPC_APP_VERSION,
    "x-rpc-channel": _conf.device_config.X_RPC_CHANNEL,
    "x-rpc-client_type": "2",
    "x-rpc-page": '',
    "x-rpc-device_fp": None,
    "x-rpc-device_id": None,
    "x-rpc-device_model": _conf.device_config.X_RPC_DEVICE_MODEL_MOBILE,
    "x-rpc-device_name": _conf.device_config.X_RPC_DEVICE_NAME_MOBILE,
    "x-rpc-sys_version": _conf.device_config.X_RPC_SYS_VERSION,

    "Connection": "keep-alive",
    "Host": "api-takumi-record.mihoyo.com"
}
class StarRailBoard(BaseModel):
    """
    崩铁实时便笺数据 (从米游社内相关页面API的返回数据初始化)
    """
    current_stamina: int
    """当前开拓力"""
    max_stamina: int
    """最大开拓力"""
    stamina_recover_time: int
    """剩余体力恢复时间"""
    current_train_score: int
    """当前每日实训值"""
    max_train_score: int
    """最大每日实训值""" 
    current_rogue_score: int
    """当前模拟宇宙积分"""
    max_rogue_score: int
    """最大模拟宇宙积分""" 
    accepted_expedition_num: int
    """已接受委托数量"""
    total_expedition_num: int
    """最大委托数量"""
    has_signed: bool
    """当天是否签到"""

    @property
    def stamina_recover_text(self):
        """
        剩余体力恢复文本
        """
        try:
            if not self.stamina_recover_time:
                return '体力未获得'
            elif self.stamina_recover_time == 0:
                return '体力已准备就绪'
            else: 
                return f'体力将在{datetime.fromtimestamp(int(time.time()) + self.stamina_recover_time)}恢复满值'
                # m, s = divmod(self.stamina_recover_time, 60)
                # h, m = divmod(m, 60) 
                # return f"{h} 小时 {m} 分钟 {s} 秒"
        except KeyError:
            return None
async def starrail_board(account: UserAccount) -> Tuple[
    Union[BaseApiStatus, StarRailBoardStatus], Optional[StarRailBoard]]:
    """
    获取崩铁实时便笺

    :param account: 用户账户数据
    """
    game_record_status, records = await get_game_record(account)
    logger.info(f"genshin_board game_record_status : {game_record_status}")
    logger.info(f"genshin_board records : {records}")
    if not game_record_status:
        return game_record_status, None
    game_list_status, game_list = await get_game_list()
    if not game_list_status:
        return game_list_status, None
    game_filter = filter(lambda x: x.en_name == 'sr', game_list)
    game_info = next(game_filter, None)
    if not game_info:
        return StarRailBoardStatus(no_starrail_account=True), None
    else:
        game_id = game_info.id
    flag = True
    for record in records:
        if record.game_id == game_id:
            try:
                flag = False 
                # params = {"role_id": record.game_role_id, "server": record.region}
                # url = f"{URL_STARRAIL_STATUS_BBS}?{urlencode(params)}"
                headers = HEADERS_STARRAIL_STATUS_WIDGET.copy()

                url = f"{URL_STARRAIL_STATUS_WIDGET}"
                # headers["x-rpc-device_id"] = account.device_id_android
                async for attempt in get_async_retry(False):
                    with attempt:
                        # headers["DS"] = generate_ds(params = params)
                        headers["DS"] = generate_ds(data = {}) 
                        async with httpx.AsyncClient() as client:

                            cookies = account.cookies.dict(v2_stoken=True, cookie_type=True)
                            logger.info(f"starrail_board headers :  {headers}")
                            logger.info(f"starrail_board cookies :  {cookies}")
                            res = await client.get(url, headers=headers,
                                                   cookies=cookies,
                                                   timeout=_conf.preference.timeout)
                        api_result = ApiResultHandler(res.json())
                        logger.info(f"simple_api starrail_board api_result : {api_result}")
                        if api_result.login_expired:
                            logger.info(
                                f"崩铁实时便笺: 用户 {account.bbs_uid} 登录失效")
                            logger.debug(f"网络请求返回: {res.text}")
                            return StarRailBoardStatus(login_expired=True), None

                        if api_result.invalid_ds:
                            logger.info(
                                f"崩铁实时便笺: 用户 {account.bbs_uid} DS 校验失败")
                            logger.debug(f"网络请求返回: {res.text}")
                        if api_result.retcode == 1034:
                            logger.info(
                                f"崩铁实时便笺: 用户 {account.bbs_uid} 可能被验证码阻拦")
                            logger.debug(f"网络请求返回: {res.text}")
                        # if api_result.invalid_ds or api_result.retcode == 1034:
                        #     headers["DS"] = generate_ds()
                        #     headers["x-rpc-device_id"] = account.device_id_ios
                        #     async with httpx.AsyncClient() as client:
                        #         res = await client.get(
                        #             URL_GENSHEN_STATUS_WIDGET,
                        #             headers=headers,
                        #             cookies=account.cookies.dict(v2_stoken=True, cookie_type=True),
                        #             timeout=_conf.preference.timeout
                        #         )
                        #     api_result = ApiResultHandler(res.json())
                        #     logger.info(f"崩铁实时便笺 api_result: {api_result}")
                        #     return StarRailBoardStatus(success=True), \
                        #         StarRailBoard.parse_obj(api_result.data)
                        return StarRailBoardStatus(success=True), StarRailBoard.parse_obj(api_result.data)
            except tenacity.RetryError as e:
                if is_incorrect_return(e):
                    logger.exception(f"崩铁实时便笺: 服务器没有正确返回")
                    logger.debug(f"网络请求返回: {res.text}")
                    return StarRailBoardStatus(incorrect_return=True), None
                else:
                    logger.exception(f"崩铁实时便笺: 请求失败")
                    return StarRailBoardStatus(network_error=True), None
    if flag:
        return StarRailBoardStatus(no_genshin_account=True), None

image

Ljzd-PRO commented 1 year ago

挺好的,可以直接提交到pull request那里 https://github.com/Ljzd-PRO/nonebot-plugin-mystool/pulls

dontdot commented 1 year ago

我这里瞎改跑通了 你试下 /game_record/app/hkrpg/api/note 玩家信息页这里内容不全,直接换成/game_record/app/hkrpg/aapi/widget小组件了

URL_STARRAIL_STATUS_WIDGET = "https://api-takumi-record.mihoyo.com/game_record/app/hkrpg/aapi/widget"

HEADERS_STARRAIL_STATUS_WIDGET = {
    "Accept": "*/*",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept-Language": "zh-CN,zh-Hans;q=0.9",
    "User-Agent": _conf.device_config.USER_AGENT_WIDGET,

    # "DS": None,
    "Referer": "https://app.mihoyo.com",
    "x-rpc-app_version": _conf.device_config.X_RPC_APP_VERSION,
    "x-rpc-channel": _conf.device_config.X_RPC_CHANNEL,
    "x-rpc-client_type": "2",
    "x-rpc-page": '',
    "x-rpc-device_fp": None,
    "x-rpc-device_id": None,
    "x-rpc-device_model": _conf.device_config.X_RPC_DEVICE_MODEL_MOBILE,
    "x-rpc-device_name": _conf.device_config.X_RPC_DEVICE_NAME_MOBILE,
    "x-rpc-sys_version": _conf.device_config.X_RPC_SYS_VERSION,

    "Connection": "keep-alive",
    "Host": "api-takumi-record.mihoyo.com"
}
class StarRailBoard(BaseModel):
    """
    崩铁实时便笺数据 (从米游社内相关页面API的返回数据初始化)
    """
    current_stamina: int
    """当前开拓力"""
    max_stamina: int
    """最大开拓力"""
    stamina_recover_time: int
    """剩余体力恢复时间"""
    current_train_score: int
    """当前每日实训值"""
    max_train_score: int
    """最大每日实训值""" 
    current_rogue_score: int
    """当前模拟宇宙积分"""
    max_rogue_score: int
    """最大模拟宇宙积分""" 
    accepted_expedition_num: int
    """已接受委托数量"""
    total_expedition_num: int
    """最大委托数量"""
    has_signed: bool
    """当天是否签到"""

    @property
    def stamina_recover_text(self):
        """
        剩余体力恢复文本
        """
        try:
            if not self.stamina_recover_time:
                return '体力未获得'
            elif self.stamina_recover_time == 0:
                return '体力已准备就绪'
            else: 
                return f'体力将在{datetime.fromtimestamp(int(time.time()) + self.stamina_recover_time)}恢复满值'
                # m, s = divmod(self.stamina_recover_time, 60)
                # h, m = divmod(m, 60) 
                # return f"{h} 小时 {m} 分钟 {s} 秒"
        except KeyError:
            return None
async def starrail_board(account: UserAccount) -> Tuple[
    Union[BaseApiStatus, StarRailBoardStatus], Optional[StarRailBoard]]:
    """
    获取崩铁实时便笺

    :param account: 用户账户数据
    """
    game_record_status, records = await get_game_record(account)
    logger.info(f"genshin_board game_record_status : {game_record_status}")
    logger.info(f"genshin_board records : {records}")
    if not game_record_status:
        return game_record_status, None
    game_list_status, game_list = await get_game_list()
    if not game_list_status:
        return game_list_status, None
    game_filter = filter(lambda x: x.en_name == 'sr', game_list)
    game_info = next(game_filter, None)
    if not game_info:
        return StarRailBoardStatus(no_starrail_account=True), None
    else:
        game_id = game_info.id
    flag = True
    for record in records:
        if record.game_id == game_id:
            try:
                flag = False 
                # params = {"role_id": record.game_role_id, "server": record.region}
                # url = f"{URL_STARRAIL_STATUS_BBS}?{urlencode(params)}"
                headers = HEADERS_STARRAIL_STATUS_WIDGET.copy()

                url = f"{URL_STARRAIL_STATUS_WIDGET}"
                # headers["x-rpc-device_id"] = account.device_id_android
                async for attempt in get_async_retry(False):
                    with attempt:
                        # headers["DS"] = generate_ds(params = params)
                        headers["DS"] = generate_ds(data = {}) 
                        async with httpx.AsyncClient() as client:

                            cookies = account.cookies.dict(v2_stoken=True, cookie_type=True)
                            logger.info(f"starrail_board headers :  {headers}")
                            logger.info(f"starrail_board cookies :  {cookies}")
                            res = await client.get(url, headers=headers,
                                                   cookies=cookies,
                                                   timeout=_conf.preference.timeout)
                        api_result = ApiResultHandler(res.json())
                        logger.info(f"simple_api starrail_board api_result : {api_result}")
                        if api_result.login_expired:
                            logger.info(
                                f"崩铁实时便笺: 用户 {account.bbs_uid} 登录失效")
                            logger.debug(f"网络请求返回: {res.text}")
                            return StarRailBoardStatus(login_expired=True), None

                        if api_result.invalid_ds:
                            logger.info(
                                f"崩铁实时便笺: 用户 {account.bbs_uid} DS 校验失败")
                            logger.debug(f"网络请求返回: {res.text}")
                        if api_result.retcode == 1034:
                            logger.info(
                                f"崩铁实时便笺: 用户 {account.bbs_uid} 可能被验证码阻拦")
                            logger.debug(f"网络请求返回: {res.text}")
                        # if api_result.invalid_ds or api_result.retcode == 1034:
                        #     headers["DS"] = generate_ds()
                        #     headers["x-rpc-device_id"] = account.device_id_ios
                        #     async with httpx.AsyncClient() as client:
                        #         res = await client.get(
                        #             URL_GENSHEN_STATUS_WIDGET,
                        #             headers=headers,
                        #             cookies=account.cookies.dict(v2_stoken=True, cookie_type=True),
                        #             timeout=_conf.preference.timeout
                        #         )
                        #     api_result = ApiResultHandler(res.json())
                        #     logger.info(f"崩铁实时便笺 api_result: {api_result}")
                        #     return StarRailBoardStatus(success=True), \
                        #         StarRailBoard.parse_obj(api_result.data)
                        return StarRailBoardStatus(success=True), StarRailBoard.parse_obj(api_result.data)
            except tenacity.RetryError as e:
                if is_incorrect_return(e):
                    logger.exception(f"崩铁实时便笺: 服务器没有正确返回")
                    logger.debug(f"网络请求返回: {res.text}")
                    return StarRailBoardStatus(incorrect_return=True), None
                else:
                    logger.exception(f"崩铁实时便笺: 请求失败")
                    return StarRailBoardStatus(network_error=True), None
    if flag:
        return StarRailBoardStatus(no_genshin_account=True), None

image

根据你这个,我也弄好了<3

dontdot commented 1 year ago

挺好的,可以直接提交到pull request那里 https://github.com/Ljzd-PRO/nonebot-plugin-mystool/pulls

要不我来pull下吧 @RemiDre

RemiDre commented 1 year ago

挺好的,可以直接提交到pull request那里 https://github.com/Ljzd-PRO/nonebot-plugin-mystool/pulls

要不我来pull下吧 @RemiDre

ok

dontdot commented 1 year ago

@Ljzd-PRO 自动检查便笺那里,异步函数要怎么改能让同时原神和崩铁一起运行

Ljzd-PRO commented 1 year ago

https://github.com/Ljzd-PRO/nonebot-plugin-mystool/blob/81038d5a06880dff99e6360af67e456608530c95/src/nonebot_plugin_mystool/plan.py#L591-L600

如果是每小时自动执行的话,在这里像resin_check那样加上崩铁的就可以

Ljzd-PRO commented 1 year ago

https://github.com/Ljzd-PRO/nonebot-plugin-mystool/blob/81038d5a06880dff99e6360af67e456608530c95/src/nonebot_plugin_mystool/plan.py#L591-L600

如果是每小时自动执行的话,在这里像resin_check那样加上崩铁的就可以

这个现在已经加上了

dontdot commented 1 year ago

https://github.com/Ljzd-PRO/nonebot-plugin-mystool/blob/81038d5a06880dff99e6360af67e456608530c95/src/nonebot_plugin_mystool/plan.py#L591-L600

如果是每小时自动执行的话,在这里像resin_check那样加上崩铁的就可以

这个现在已经加上了

plan.resin_check_sr的函数的推送可能有点问题

07-19 14:34:29 [INFO] nonebot_plugin_mystool | 原神实时便笺: 用户 123 可能被验证码阻拦
07-19 14:34:29 [DEBUG] nonebot_plugin_mystool | 网络请求返回: {"data":null,"message":"","retcode":1034}
07-19 14:34:30 [INFO] nonebot_plugin_mystool | success=True network_error=False incorrect_return=False login_expired=False need_verify=False invalid_ds=False no_genshin_account=False
07-19 14:34:31 [DEBUG] nonebot | OneBot V11 | Calling API send_private_msg
07-19 14:34:37 [INFO] nonebot_plugin_mystool | success=True network_error=False incorrect_return=False login_expired=False need_verify=False invalid_ds=False no_starrail_account=False

有显示starrail相关的信息,resin_check_sr应该有运行的,有可能是后面的msg相关的出问题导致没有推送