nek0us / nonebot_plugin_steam_game_status

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

Cannot choose from an empty sequence #23

Closed XokoukioX closed 2 months ago

XokoukioX commented 2 months ago

在群聊中发送连接之后 机器人报错

我:https://store.steampowered.com/app/1351240/_/ 机器人:未回复

后台日志 08-06 11:01:04 [SUCCESS] nonebot | OneBot V11 3CXXXXXX7 | [message.group.normal]: Message 1XXXXXX9 from 3282076201@[群:1XXXXXXX9] 'https://store.steampowered.com/app/1351240/_/' 08-06 11:01:04 [INFO] nonebot | Event will be handled by Matcher(type='message', module=nonebot_plugin_steam_game_status, lineno=111) 08-06 11:01:10 [INFO] nonebot | Matcher(type='message', module=nonebot_plugin_steam_game_status, lineno=111) running complete 08-06 11:01:10 [ERROR] nonebot | Running Matcher(type='message', module=nonebot_plugin_steam_game_status, lineno=111) failed. Traceback (most recent call last): File "", line 17, in File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/nonebot/init.py", line 335, in run get_driver().run(*args, **kwargs) File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/nonebot/drivers/fastapi.py", line 186, in run uvicorn.run( File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/uvicorn/main.py", line 577, in run server.run() File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/uvicorn/server.py", line 65, in run return asyncio.run(self.serve(sockets=sockets)) File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run return runner.run(main) File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/nonebot/message.py", line 476, in check_and_run_matcher await _run_matcher(

File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/nonebot/message.py", line 428, in _run_matcher await matcher.run(bot, event, state, stack, dependency_cache) File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/nonebot/internal/matcher/matcher.py", line 850, in run await self.simple_run(bot, event, state, stack, dependency_cache) File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/nonebot/internal/matcher/matcher.py", line 825, in simple_run await handler( File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/nonebot/dependencies/init.py", line 94, in call return await cast(Callable[..., Awaitable[R]], self.call)(**values) File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/nonebot_plugin_steam_game_status/init.py", line 128, in steam_link_handle MessageSegment.text(f"{random.choice(bot_name)}也想玩" if tmp['is_free'] else f"要送给{random.choice(bot_name)}吗?") File "/usr/lib/python3.12/random.py", line 347, in choice raise IndexError('Cannot choose from an empty sequence') IndexError: Cannot choose from an empty sequence

nek0us commented 2 months ago

是不是配置文件里没配置BOT_NAME

XokoukioX commented 2 months ago

在.env中设置bot_name之后,再次尝试输出如下错误 image

后台日志如下: {'OneBot V11': <function list_targets at 0x76be89746c00>, 'OneBot V12': <function listtargets at 0x76be89746840>} 08-06 11:10:38 [SUCCESS] nonebot | OneBot V11 3XXX47 | [message.group.normal]: Message 140XX349 from 3282076201@[群:1001378519] 'https://store.steampowered.com/app/1351240//' 08-06 11:10:38 [INFO] nonebot | Event will be handled by Matcher(type='message', module=nonebot_plugin_steam_game_status, lineno=111) 08-06 11:10:43 [WARNING] nonebot_plugin_steam_game_status | steam链接识别失败,异常为: 08-06 11:10:43 [INFO] nonebot | Matcher(type='message', module=nonebot_plugin_steam_gamestatus, lineno=111) running complete 08-06 11:10:49 [SUCCESS] nonebot | OneBot V11 38XX547 | [message.group.normal]: Message 20XXX02 from 3282076201@[群:100XXX519] 'https://store.steampowered.com/app/1351240//' 08-06 11:10:49 [INFO] nonebot | Event will be handled by Matcher(type='message', module=nonebot_plugin_steam_game_status, lineno=111) 08-06 11:10:54 [WARNING] nonebot_plugin_steam_game_status | steam链接识别失败,异常为: 08-06 11:10:54 [INFO] nonebot | Matcher(type='message', module=nonebot_plugin_steam_gamestatus, lineno=111) running complete 08-06 11:10:59 [SUCCESS] nonebot | OneBot V11 3XXX47 | [message.group.normal]: Message 1295847269 from 3282076201@[群:10XXX19] 'https://store.steampowered.com/app/1351240//' 08-06 11:10:59 [INFO] nonebot | Event will be handled by Matcher(type='message', module=nonebot_plugin_steam_game_status, lineno=111) 08-06 11:11:06 [INFO] nonebot | Matcher(type='message', module=nonebot_plugin_steam_game_status, lineno=111) running complete 08-06 11:11:06 [ERROR] nonebot | Running Matcher(type='message', module=nonebot_plugin_steam_game_status, lineno=111) failed. Traceback (most recent call last): File "", line 17, in File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/nonebot/init.py", line 335, in run get_driver().run(*args, **kwargs) File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/nonebot/drivers/fastapi.py", line 186, in run uvicorn.run( File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/uvicorn/main.py", line 577, in run server.run() File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/uvicorn/server.py", line 65, in run return asyncio.run(self.serve(sockets=sockets)) File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run return runner.run(main) File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/nonebot/message.py", line 476, in check_and_run_matcher await _run_matcher(

File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/nonebot/message.py", line 428, in _run_matcher await matcher.run(bot, event, state, stack, dependency_cache) File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/nonebot/internal/matcher/matcher.py", line 850, in run await self.simple_run(bot, event, state, stack, dependency_cache) File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/nonebot/internal/matcher/matcher.py", line 825, in simple_run await handler( File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/nonebot/dependencies/init.py", line 94, in call return await cast(Callable[..., Awaitable[R]], self.call)(**values) File "/home/kawakaze/qqbot/test/.venv/lib/python3.12/site-packages/nonebot_plugin_steam_game_status/init.py", line 128, in steam_link_handle MessageSegment.text(f"{random.choice(bot_name)}也想玩" if tmp['is_free'] else f"要送给{random.choice(bot_name)}吗?") File "/usr/lib/python3.12/random.py", line 347, in choice raise IndexError('Cannot choose from an empty sequence') IndexError: Cannot choose from an empty sequence

nek0us commented 2 months ago

家庭环境吗?试试配置下steam_proxy代理呢

XokoukioX commented 2 months ago

成功解决!谢谢作者! PS:steamapi仍然需要以数组方式录入