HibiKier / zhenxun_bot

基于 Nonebot2 开发,非常可爱的绪山真寻bot
GNU Affero General Public License v3.0
3.35k stars 605 forks source link

更新色图出错 #1242

Closed PackageInstaller closed 1 year ago

PackageInstaller commented 1 year ago

系统版本:Arch Linux 6.1.8-arch1-1

真寻版本:V0.1.6.6

错误截图

Screenshot_20230127_112532

日志截图

01-27 11:25:31 [ERROR] nonebot | Running Matcher(type='message', module=plugins.sendsetu.update_setu) failed. Traceback (most recent call last):

File "/home/Neko/QQBot/zhenxun_bot/plugins/sendsetu/update_setu/data_source.py", line 148, in update_setu_img img_hash = str(get_img_hash(f"{path}/{image.local_id}.jpg")) └ <function get_img_hash at 0x7f5e458dec20>

File "/home/Neko/QQBot/zhenxun_bot/utils/image_utils.py", line 56, in get_img_hash hash_value = imagehash.average_hash(Image.open(fp)) │ │ │ │ └ <_io.BufferedReader name='resources/image/_setu/14630.jpg'> │ │ │ └ <function open at 0x7f5e4b942ef0> │ │ └ <module 'PIL.Image' from '/home/Neko/.cache/pypoetry/virtualenvs/zhenxun-bot-PzlhPUjk-py3.10/lib/python3.10/site-packages/PIL... │ └ <function average_hash at 0x7f5e4b94beb0> └ <module 'imagehash' from '/home/Neko/.cache/pypoetry/virtualenvs/zhenxun-bot-PzlhPUjk-py3.10/lib/python3.10/site-packages/ima...

File "/home/Neko/.cache/pypoetry/virtualenvs/zhenxun-bot-PzlhPUjk-py3.10/lib/python3.10/site-packages/PIL/Image.py", line 3186, in open raise UnidentifiedImageError( └ <class 'PIL.UnidentifiedImageError'>

PIL.UnidentifiedImageError: cannot identify image file <_io.BufferedReader name='resources/image/_setu/14630.jpg'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/home/Neko/QQBot/zhenxun_bot/bot.py", line 21, in nonebot.run() │ └ <function run at 0x7f5e7a01fbe0> └ <module 'nonebot' from '/home/Neko/.cache/pypoetry/virtualenvs/zhenxun-bot-PzlhPUjk-py3.10/lib/python3.10/site-packages/noneb...

File "/home/Neko/.cache/pypoetry/virtualenvs/zhenxun-bot-PzlhPUjk-py3.10/lib/python3.10/site-packages/nonebot/init.py", line 273, in run get_driver().run(*args, **kwargs) │ │ └ {} │ └ () └ <function get_driver at 0x7f5e7a01f520> File "/home/Neko/.cache/pypoetry/virtualenvs/zhenxun-bot-PzlhPUjk-py3.10/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 172, in run uvicorn.run( │ └ <function run at 0x7f5e78c3a050> └ <module 'uvicorn' from '/home/Neko/.cache/pypoetry/virtualenvs/zhenxun-bot-PzlhPUjk-py3.10/lib/python3.10/site-packages/uvico... File "/home/Neko/.cache/pypoetry/virtualenvs/zhenxun-bot-PzlhPUjk-py3.10/lib/python3.10/site-packages/uvicorn/main.py", line 569, in run server.run() │ └ <function Server.run at 0x7f5e78c3a200> └ <uvicorn.server.Server object at 0x7f5d8b080ee0> File "/home/Neko/.cache/pypoetry/virtualenvs/zhenxun-bot-PzlhPUjk-py3.10/lib/python3.10/site-packages/uvicorn/server.py", line 60, in run return asyncio.run(self.serve(sockets=sockets)) │ │ │ │ └ None │ │ │ └ <function Server.serve at 0x7f5e78c3a290> │ │ └ <uvicorn.server.Server object at 0x7f5d8b080ee0> │ └ <function run at 0x7f5e7b145510> └ <module 'asyncio' from '/usr/lib/python3.10/asyncio/init.py'> File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) │ │ └ <coroutine object Server.serve at 0x7f5d8b3dece0> │ └ <method 'run_until_complete' of 'uvloop.loop.Loop' objects> └ File "/home/Neko/.cache/pypoetry/virtualenvs/zhenxun-bot-PzlhPUjk-py3.10/lib/python3.10/site-packages/nonebot/message.py", line 142, in _check_matcher await _run_matcher(Matcher, bot, event, state, stack, dependency_cache) │ │ │ │ │ │ └ {<function _event_to_me at 0x7f5e79d03400>: <Task finished name='Task-90579' coro=<_event_to_me() done, defined at /home/Neko... │ │ │ │ │ └ <contextlib.AsyncExitStack object at 0x7f5e73bcc7f0> │ │ │ │ └ {'_prefix': {'command': ('更新色图',), 'raw_command': '更新色图', 'command_arg': [], 'command_start': ''}} │ │ │ └ PrivateMessageEvent(time=1674789929, self_id=3042447114, post_type='message', sub_type='friend', userid=3420224707, message... │ │ └ Bot(type='OneBot V11', self_id='3042447114') │ └ Matcher(type='message', module=plugins.sendsetu.update_setu) └ <function _run_matcher at 0x7f5e79c4a9e0>

File "/home/Neko/.cache/pypoetry/virtualenvs/zhenxun-bot-PzlhPUjk-py3.10/lib/python3.10/site-packages/nonebot/message.py", line 188, in _run_matcher await matcher.run(bot, event, state, stack, dependency_cache) │ │ │ │ │ │ └ {<function _event_to_me at 0x7f5e79d03400>: <Task finished name='Task-90579' coro=<_event_to_me() done, defined at /home/Neko... │ │ │ │ │ └ <contextlib.AsyncExitStack object at 0x7f5e73bcc7f0> │ │ │ │ └ {'_prefix': {'command': ('更新色图',), 'raw_command': '更新色图', 'command_arg': [], 'command_start': ''}} │ │ │ └ PrivateMessageEvent(time=1674789929, self_id=3042447114, post_type='message', sub_type='friend', userid=3420224707, message... │ │ └ Bot(type='OneBot V11', self_id='3042447114') │ └ <function Matcher.run at 0x7f5e79d031c0> └ Matcher(type='message', module=plugins.sendsetu.update_setu) File "/home/Neko/.cache/pypoetry/virtualenvs/zhenxun-bot-PzlhPUjk-py3.10/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 727, in run await self.simple_run(bot, event, state, stack, dependency_cache) │ │ │ │ │ │ └ {<function _event_to_me at 0x7f5e79d03400>: <Task finished name='Task-90579' coro=<_event_to_me() done, defined at /home/Neko... │ │ │ │ │ └ <contextlib.AsyncExitStack object at 0x7f5e73bcc7f0> │ │ │ │ └ {'_prefix': {'command': ('更新色图',), 'raw_command': '更新色图', 'command_arg': [], 'command_start': ''}} │ │ │ └ PrivateMessageEvent(time=1674789929, self_id=3042447114, post_type='message', sub_type='friend', userid=3420224707, message... │ │ └ Bot(type='OneBot V11', self_id='3042447114') │ └ <function Matcher.simple_run at 0x7f5e79d03130> └ Matcher(type='message', module=plugins.sendsetu.update_setu) File "/home/Neko/.cache/pypoetry/virtualenvs/zhenxun-bot-PzlhPUjk-py3.10/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 702, in simplerun await handler( └ Dependent(call=) File "/home/Neko/.cache/pypoetry/virtualenvs/zhenxun-bot-PzlhPUjk-py3.10/lib/python3.10/site-packages/nonebot/dependencies/init.py", line 108, in call return await cast(Callable[..., Awaitable[R]], self.call)(**values) │ │ │ │ │ │ └ {} │ │ │ │ │ └ <function at 0x7f5e3de54b80> │ │ │ │ └ Dependent(call=) │ │ │ └ ~R │ │ └ typing.Awaitable │ └ typing.Callable └ <function cast at 0x7f5e7b1c5480>

File "/home/Neko/QQBot/zhenxun_bot/plugins/sendsetu/updatesetu/init.py", line 33, in await update_setu_img(True) └ <function update_setu_img at 0x7f5e3de54430>

File "/home/Neko/QQBot/zhenxun_bot/plugins/sendsetu/update_setu/data_source.py", line 154, in update_setu_img max_num = await Setu.delete_image(image.pid) │ │ │ └ <gino.declarative.ColumnAttribute object at 0x7f5e3de37310> │ │ └ <plugins.sendsetu._model.Setu object at 0x7f5e74180d60> │ └ <classmethod(<function Setu.delete_image at 0x7f5e3de54820>)> └ <class 'plugins.sendsetu._model.Setu'>

File "/home/Neko/QQBot/zhenxun_bot/plugins/sendsetu/_model.py", line 140, in delete_image _tmp_local_id = x.local_id └ None

AttributeError: 'NoneType' object has no attribute 'local_id'

错误说明

1.更新色图一直卡在14630这张图片这里,看了一下这张图是一张58B的坏图,用本地相册显示打开失败,删除这图再更新到这里还是会卡住,跪求一个解决方法 2.换了自己的反代,但是更新色图时utils插件还是用的默认的反代,不知道这么解决 image

HibiKier commented 1 year ago

已重构