RF-Tar-Railt / nonebot-plugin-arkgacha

Plugin for Arknights gacha, support multi platform
GNU Affero General Public License v3.0
15 stars 1 forks source link

Bug: 抽卡出现异常 IndexError: Cannot choose from an empty sequence #17

Open Cysime opened 5 days ago

Cysime commented 5 days ago

操作系统

Linux

Python 版本

3.12

NoneBot 版本

2.4.0

适配器

Onebot V11

描述问题

输入抽卡指令,不返回任何结果,同时报错:IndexError: Cannot choose from an empty sequence

可以正常初始化,也不影响其它插件。具体log可以见下面。

另外,卡池信息可能需要更新了,使用arkkit init的时候 阿米娅(医疗) 图片404了。 2024-11-28 05:03:31.753 | ERROR | arknights_toolkit.update.main:fetch_image:160 - failed to get image of 阿米娅(医疗): status code: 404

复现步骤

正常下载插件所需图片资源:nb arkgacha init

运行Bot并初始化正常:nb run --reload

在QQ上对机器人发出指令 方舟抽卡 方舟十连,不返回结果并报错。

期望的结果

输出抽卡结果

截图或日志

11-28 04:57:37 [INFO] nonebot | Event will be handled by Matcher(type='message', module=nonebot_plugin_arkgacha, lineno=74)
11-28 04:57:37 [INFO] nonebot | Matcher(type='message', module=nonebot_plugin_arkgacha, lineno=74) running complete
11-28 04:57:37 [ERROR] nonebot | Running Matcher(type='message', module=nonebot_plugin_arkgacha, lineno=74) failed.
Traceback (most recent call last):
  File "<string>", line 17, in <module>
  File "/home/ubuntu/nonebot/GlaceonBot/.venv/lib/python3.12/site-packages/nonebot/__init__.py", line 335, in run
    get_driver().run(*args, **kwargs)
  File "/home/ubuntu/nonebot/GlaceonBot/.venv/lib/python3.12/site-packages/nonebot/drivers/fastapi.py", line 186, in run
    uvicorn.run(
  File "/home/ubuntu/nonebot/GlaceonBot/.venv/lib/python3.12/site-packages/uvicorn/main.py", line 579, in run
    server.run()
  File "/home/ubuntu/nonebot/GlaceonBot/.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/ubuntu/nonebot/GlaceonBot/.venv/lib/python3.12/site-packages/nonebot/message.py", line 476, in check_and_run_matcher
    await _run_matcher(
> File "/home/ubuntu/nonebot/GlaceonBot/.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/ubuntu/nonebot/GlaceonBot/.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/ubuntu/nonebot/GlaceonBot/.venv/lib/python3.12/site-packages/nonebot/internal/matcher/matcher.py", line 825, in simple_run
    await handler(
  File "/home/ubuntu/nonebot/GlaceonBot/.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/ubuntu/nonebot/GlaceonBot/.venv/lib/python3.12/site-packages/nonebot_plugin_arkgacha/__init__.py", line 188, in _
    res = gacha.gacha(user, 10)
  File "/home/ubuntu/nonebot/GlaceonBot/.venv/lib/python3.12/site-packages/arknights_toolkit/gacha/main.py", line 99, in gacha
    cache.append(self.generate_operator(ans))
  File "/home/ubuntu/nonebot/GlaceonBot/.venv/lib/python3.12/site-packages/arknights_toolkit/gacha/main.py", line 134, in generate_operator
    return Operator(random.choice(card_list), 4)
  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
Cysime commented 5 days ago

重新又试了一下,发现是 nb arkgacha init 这个命令初始化有问题: 首次安装,使用的是 nb arkgacha init 命令,就会如此报错,是不是用nb命令的时候其实数据并没有正常写进去? 自己手动进入虚拟环境后,重新使用 arkkit init -SIMG 就没问题了,正常使用。