nek0us / nonebot_plugin_steam_game_status

在群内播报steam游戏状态的Nonebot插件
GNU General Public License v3.0
47 stars 6 forks source link

更新到最新版本后无法主动推送信息,steam列表指令可以查看到正在玩的游戏 #25

Open Priopus opened 3 weeks ago

Priopus commented 3 weeks ago

更新最新版本之后不主动推送消息了,看了下debug查询是能正常查询并改变json的状态,还有用steam列表查询的话可以查询出正在玩,但是就是不推送,看查询任务状态失败那里是不是因为api返回的格式改了导致不能正常触发推送?


10-31 15:12:25 [DEBUG] nonebot | Running PreProcessors...
10-31 15:13:21 [DEBUG] nonebot_plugin_steam_game_status | steam准备开始生成查询字典
10-31 15:13:21 [DEBUG] nonebot_plugin_steam_game_status | steam生成查询字典完成,准备添加任务
10-31 15:13:21 [DEBUG] nonebot_plugin_steam_game_status | steam添加任务完成,准备运行并等待任务
10-31 15:13:22 [DEBUG] nonebot_plugin_steam_game_status | steam自动查询任务完成
10-31 15:13:22 [DEBUG] nonebot_plugin_steam_game_status | steam状态信息: {'76561198413624051': [-1, '', 'spyker']}
10-31 15:13:22 [DEBUG] nonebot_plugin_steam_game_status | steam finally保存完成
10-31 15:13:25 [DEBUG] nonebot | Running PreProcessors...
10-31 15:14:21 [DEBUG] nonebot_plugin_steam_game_status | steam准备开始生成查询字典
10-31 15:14:21 [DEBUG] nonebot_plugin_steam_game_status | steam生成查询字典完成,准备添加任务
10-31 15:14:21 [DEBUG] nonebot_plugin_steam_game_status | steam添加任务完成,准备运行并等待任务
10-31 15:14:22 [DEBUG] nonebot_plugin_steam_game_status | steam id:76561198413624051 查询状态失败,list indices must be integers or slices, not str
{"response":{"players":[{"steamid":"76561198413624051","communityvisibilitystate":3,"profilestate":1,"personaname":"spyker","profileurl":"https://steamcommunity.com/profiles/76561198413624051/","avatar":"https://avatars.steamstatic.com/3621dc58a13d31b373ac1ed42a195710b67d8da4.jpg","avatarmedium":"https://avatars.steamstatic.com/3621dc58a13d31b373ac1ed42a195710b67d8da4_medium.jpg","avatarfull":"https://avatars.steamstatic.com/3621dc58a13d31b373ac1ed42a195710b67d8da4_full.jpg","avatarhash":"3621dc58a13d31b373ac1ed42a195710b67d8da4","lastlogoff":1728915895,"personastate":1,"primaryclanid":"103582791429521408","timecreated":1503064411,"personastateflags":0,"gameextrainfo":"House Flipper","gameid":"613100","loccountrycode":"CN","locstatecode":"16","loccityid":10230}]}}
10-31 15:14:23 [DEBUG] nonebot_plugin_steam_game_status | steam自动查询任务完成
10-31 15:14:23 [DEBUG] nonebot_plugin_steam_game_status | steam状态信息: {'76561198413624051': [28839314, '房产达人', 'spyker']}
10-31 15:14:23 [DEBUG] nonebot_plugin_steam_game_status | steam finally保存完成
10-31 15:14:25 [DEBUG] nonebot | Running PreProcessors...
10-31 15:15:21 [DEBUG] nonebot_plugin_steam_game_status | steam准备开始生成查询字典
10-31 15:15:21 [DEBUG] nonebot_plugin_steam_game_status | steam生成查询字典完成,准备添加任务
10-31 15:15:21 [DEBUG] nonebot_plugin_steam_game_status | steam添加任务完成,准备运行并等待任务
10-31 15:15:23 [DEBUG] nonebot_plugin_steam_game_status | steam自动查询任务完成
10-31 15:15:23 [DEBUG] nonebot_plugin_steam_game_status | steam状态信息: {'76561198413624051': [28839314, '房产达人', 'spyker']}
10-31 15:15:23 [DEBUG] nonebot_plugin_steam_game_status | steam finally保存完成
10-31 15:15:25 [DEBUG] nonebot | Running PreProcessors...```
nek0us commented 3 weeks ago

可以编辑到本地的插件代码文件吗? 如果可以的话,在 本插件包目录的__init__.py里的265行的except Exception as e:后面,将代码改成下方这样:

    except Exception as e:
        import sys
        _, _, exc_traceback = sys.exc_info()
        logger.debug(f"steam id:{steam_id} 查询状态失败,行号 {exc_traceback.tb_lineno}, {e}\n 用户信息: \n{user_info}\n steam列表:\n{steam_list}\n 排除游戏列表:\n{exclude_game}\n steamid转换列表:\n{steam_id_to_groups} \n{res.text}")

然后再看一看日志

Priopus commented 3 weeks ago

可以编辑到本地的插件代码文件吗? 如果可以的话,在 本插件包目录的__init__.py里的265行的except Exception as e:后面,将代码改成下方这样:

    except Exception as e:
        import sys
        _, _, exc_traceback = sys.exc_info()
        logger.debug(f"steam id:{steam_id} 查询状态失败,行号 {exc_traceback.tb_lineno}, {e}\n 用户信息: \n{user_info}\n steam列表:\n{steam_list}\n 排除游戏列表:\n{exclude_game}\n steamid转换列表:\n{steam_id_to_groups} \n{res.text}")

然后再看一看日志

10-31 17:22:38 [DEBUG] nonebot_plugin_steam_game_status | steam id:76561198413624051 查询状态失败,行号 224, list indices must be integers or slices, not str
 用户信息:
[28839442, '', 'spyker']
 steam列表:
{'76561198413624051': [-1, '房产达人', 'spyker']}
 排除游戏列表:
['Wallpaper Engine:壁纸引擎', '虚拟桌宠模拟器', 'OVR Toolkit', 'OVR Advanced Settings', 'OBS Studio', 'VTube Studio', 'Live2DViewerEX', 'Blender', 'LIV']
 steamid转换列表:
{'76561198413624051': ['559307139']}
{"response":{"players":[{"steamid":"76561198413624051","communityvisibilitystate":3,"profilestate":1,"personaname":"spyker","profileurl":"https://steamcommunity.com/profiles/76561198413624051/","avatar":"https://avatars.steamstatic.com/3621dc58a13d31b373ac1ed42a195710b67d8da4.jpg","avatarmedium":"https://avatars.steamstatic.com/3621dc58a13d31b373ac1ed42a195710b67d8da4_medium.jpg","avatarfull":"https://avatars.steamstatic.com/3621dc58a13d31b373ac1ed42a195710b67d8da4_full.jpg","avatarhash":"3621dc58a13d31b373ac1ed42a195710b67d8da4","lastlogoff":1728915895,"personastate":1,"primaryclanid":"103582791429521408","timecreated":1503064411,"personastateflags":0,"loccountrycode":"CN","locstatecode":"16","loccityid":10230}]}}
Priopus commented 3 weeks ago

我的224行应该是这个起,前面加了一行日志输出

                            if game_name_old in exclude_game[str(group_id)]:
                                logger.trace(f"群 {group_id} 因游戏名单跳过发送 steam id {steam_id},name {res_info['personaname']} 重启之前停止的游戏: {game_name_old}")
                                continue
Priopus commented 3 weeks ago

启动游戏的时候debug是这个

10-31 17:52:38 [DEBUG] nonebot_plugin_steam_game_status | steam id:76561198413624051 查询状态失败,行号 187, list indices must be integers or slices, not str
 用户信息:
[28839472, '房产达人', 'spyker']
 steam列表:
{'76561198413624051': [28839442, '', 'spyker']}
 排除游戏列表:
['Wallpaper Engine:壁纸引擎', '虚拟桌宠模拟器', 'OVR Toolkit', 'OVR Advanced Settings', 'OBS Studio', 'VTube Studio', 'Live2DViewerEX', 'Blender', 'LIV']
 steamid转换列表:
{ '76561198413624051': ['559307139']}
{"response":{"players":[{"steamid":"76561198413624051","communityvisibilitystate":3,"profilestate":1,"personaname":"spyker","profileurl":"https://steamcommunity.com/profiles/76561198413624051/","avatar":"https://avatars.steamstatic.com/3621dc58a13d31b373ac1ed42a195710b67d8da4.jpg","avatarmedium":"https://avatars.steamstatic.com/3621dc58a13d31b373ac1ed42a195710b67d8da4_medium.jpg","avatarfull":"https://avatars.steamstatic.com/3621dc58a13d31b373ac1ed42a195710b67d8da4_full.jpg","avatarhash":"3621dc58a13d31b373ac1ed42a195710b67d8da4","lastlogoff":1730366961,"personastate":1,"primaryclanid":"103582791429521408","timecreated":1503064411,"personastateflags":0,"gameextrainfo":"House Flipper","gameid":"613100","loccountrycode":"CN","locstatecode":"16","loccityid":10230}]}}

对应的187行代码是:

                        if game_name in exclude_game[str(group_id)]:
                            logger.trace(f"群 {group_id} 因游戏名单跳过发送 steam id {steam_id},name {res_info['personaname']} 正在玩的游戏 {game_name}")
                            continue
                        logger.trace(f"群 {group_id} 准备发送 steam id {steam_id},name {res_info['personaname']} 正在玩的游戏 {game_name}")
                        await tools.send_group_msg_by_bots_once(group_id=int(group_id),msg=Message(f"{res_info['personaname']} 开始玩 {game_name} 。"))
nek0us commented 3 weeks ago

清空一下用户目录下的该插件数据目录试试,比如说~/.local/share/nonebot2/nonebot_plugin_steam_game_status/{bot_name}/ windows下是C:\Users\{UserName}\AppData\Local\nonebot2\nonebot_plugin_steam_game_status\{bot_name} 可以先移动剪切走,看看效果

Priopus commented 3 weeks ago

清空一下用户目录下的该插件数据目录试试,比如说~/.local/share/nonebot2/nonebot_plugin_steam_game_status/{bot_name}/ windows下是C:\Users\{UserName}\AppData\Local\nonebot2\nonebot_plugin_steam_game_status\{bot_name} 可以先移动剪切走,看看效果

清空重写可以了,盲猜应该是跨版本升级,然后从旧目录同步过来的时候有报错没迁移成功,我刚看是同步了两个json,另外两个生成报错,是不是应该把新版本需要迁移的四个文件分开判断?

11-01 00:09:31 [ERROR] nonebot | Failed to import "nonebot_plugin_steam_game_status"
Traceback (most recent call last):
  File "H:\QQbot\ayakabot\bot.py", line 14, in <module>
    nonebot.load_from_toml("pyproject.toml")
  File "H:\QQbot\ayakabot\.venv\lib\site-packages\nonebot\plugin\load.py", line 130, in load_from_toml
    return load_all_plugins(plugins, plugin_dirs)
  File "H:\QQbot\ayakabot\.venv\lib\site-packages\nonebot\plugin\load.py", line 64, in load_all_plugins
    return manager.load_all_plugins()
  File "H:\QQbot\ayakabot\.venv\lib\site-packages\nonebot\plugin\manager.py", line 176, in load_all_plugins
    return set(
  File "H:\QQbot\ayakabot\.venv\lib\site-packages\nonebot\plugin\manager.py", line 177, in <genexpr>
    filter(None, (self.load_plugin(name) for name in self.available_plugins))
> File "H:\QQbot\ayakabot\.venv\lib\site-packages\nonebot\plugin\manager.py", line 142, in load_plugin
    module = importlib.import_module(name)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "H:\QQbot\ayakabot\.venv\lib\site-packages\nonebot\plugin\manager.py", line 242, in exec_module
    super().exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "H:\QQbot\ayakabot\.venv\lib\site-packages\nonebot_plugin_steam_game_status\__init__.py", line 36, in <module>
    gameid2name = json.loads(game_cache_file.read_text("utf8"))
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\pathlib.py", line 1134, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\pathlib.py", line 1119, in open
    return self._accessor.open(self, mode, buffering, encoding, errors,
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Administrator\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\Local\\nonebot2\\nonebot_plugin_steam_game_status\\ayakabot\\game_cache.json'
nek0us commented 3 weeks ago

清空一下用户目录下的该插件数据目录试试,比如说~/.local/share/nonebot2/nonebot_plugin_steam_game_status/{bot_name}/ windows下是C:\Users\{UserName}\AppData\Local\nonebot2\nonebot_plugin_steam_game_status\{bot_name} 可以先移动剪切走,看看效果

清空重写可以了,盲猜应该是跨版本升级,然后从旧目录同步过来的时候有报错没迁移成功,我刚看是同步了两个json,另外两个生成报错,是不是应该把新版本需要迁移的四个文件分开判断?

11-01 00:09:31 [ERROR] nonebot | Failed to import "nonebot_plugin_steam_game_status"
Traceback (most recent call last):
  File "H:\QQbot\ayakabot\bot.py", line 14, in <module>
    nonebot.load_from_toml("pyproject.toml")
  File "H:\QQbot\ayakabot\.venv\lib\site-packages\nonebot\plugin\load.py", line 130, in load_from_toml
    return load_all_plugins(plugins, plugin_dirs)
  File "H:\QQbot\ayakabot\.venv\lib\site-packages\nonebot\plugin\load.py", line 64, in load_all_plugins
    return manager.load_all_plugins()
  File "H:\QQbot\ayakabot\.venv\lib\site-packages\nonebot\plugin\manager.py", line 176, in load_all_plugins
    return set(
  File "H:\QQbot\ayakabot\.venv\lib\site-packages\nonebot\plugin\manager.py", line 177, in <genexpr>
    filter(None, (self.load_plugin(name) for name in self.available_plugins))
> File "H:\QQbot\ayakabot\.venv\lib\site-packages\nonebot\plugin\manager.py", line 142, in load_plugin
    module = importlib.import_module(name)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "H:\QQbot\ayakabot\.venv\lib\site-packages\nonebot\plugin\manager.py", line 242, in exec_module
    super().exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "H:\QQbot\ayakabot\.venv\lib\site-packages\nonebot_plugin_steam_game_status\__init__.py", line 36, in <module>
    gameid2name = json.loads(game_cache_file.read_text("utf8"))
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\pathlib.py", line 1134, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\pathlib.py", line 1119, in open
    return self._accessor.open(self, mode, buffering, encoding, errors,
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Administrator\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\Local\\nonebot2\\nonebot_plugin_steam_game_status\\ayakabot\\game_cache.json'

未来添加