Yuri-YuzuChaN / maimaiDX

基于HoshinoBot V2的舞萌DX查询插件,移植自mai-bot开源项目
MIT License
200 stars 32 forks source link

b40指令报错 #29

Closed ghost closed 2 years ago

ghost commented 2 years ago

系统环境ubuntu 22.04 lts w/ python 3.10.4 (system) 已手动pip3 -U升级nonebot和aiocqhttp

Note: pyenv 3.9.12环境下正常运行

[2022-04-22 15:33:19,625 maimaiDX] INFO: Message -421822641 triggered best_40.
[2022-04-22 15:33:20,750 maimaiDX] ERROR: <class 'TypeError'> occured when best_40 handling message -421822641.
[2022-04-22 15:33:20,751 maimaiDX] ERROR: 'float' object cannot be interpreted as an integer
Traceback (most recent call last):
  File "/home/risa/maimaidx/HoshinoBot/hoshino/msghandler.py", line 28, in handle_message
    await service_func.func(bot, event)
  File "/home/risa/maimaidx/HoshinoBot/hoshino/modules/maimaiDX/maimai.py", line 397, in best_40
    data = await generate(payload)
  File "/home/risa/maimaidx/HoshinoBot/hoshino/modules/maimaiDX/libraries/maimai_best_40.py", line 533, in generate
    pic = await draw_best.draw()
  File "/home/risa/maimaidx/HoshinoBot/hoshino/modules/maimaiDX/libraries/maimai_best_40.py", line 449, in draw
    self._drawBestList(self.img, self.sdBest, self.dxBest)
  File "/home/risa/maimaidx/HoshinoBot/hoshino/modules/maimaiDX/libraries/maimai_best_40.py", line 296, in _drawBestList
    temp = temp.point(lambda p: p * 0.72)
  File "/home/risa/.local/lib/python3.10/site-packages/PIL/Image.py", line 1723, in point
    return self._new(self.im.point(lut, mode))
TypeError: 'float' object cannot be interpreted as an integer
[2022-04-22 15:33:20,753 nonebot] INFO: Message -421822641 is ignored: Handled by Hoshino
BlueDeer233 commented 2 years ago

maimai_best_40.py line 296 改成这样试试:temp = temp.point(lambda p: int(p * 0.72)) 我们无法复现这个issue,不太敢直接修改repo

ghost commented 2 years ago

感谢回复 我这边的复现方法如下 在虚拟机内用 ubuntu-22.04-live-server-amd64.iso 全新安装ubuntu server 安装过程中不选择其他附加软件 安装后正常apt 更新

sudo apt install python3-pip
pip3 install -r requirements.txt  // HoshinoBot依赖
pip3 install pillow retrying ujson msgpack // maimaiDX和其他依赖
pip3 install -U nonebot aiocqhttp // 更新cqhttp lib

__bot__.py 中仅启用 botmanagermaimaiDX 两个插件 其余不作改动 随后直接运行 python3 run.py 使用系统的 python(3.10.4) 运行bot 在开启maimaidx功能的群内输入 b40 指令 则可以触发此问题 Line 296 321 345 370 依次修改后可正常运行

ghost commented 2 years ago

翻了下 python 3.10 changlog

Builtin and extension functions that take integer arguments no longer accept Decimals, Fractions and other objects that can be converted to integers only with a loss (e.g. that have the int() method but do not have the index() method). (Contributed by Serhiy Storchaka in bpo-37999.)

确定是python更新导致的 也许我该测试一下修改后能否兼容 Python 3.9 及以前版本

ghost commented 2 years ago

Archived for reference. Fixed in upstream: https://github.com/Diving-Fish/mai-bot/commit/6e95d48b55f93b3748d603908fea77c469fd270f