调用bot.send()报错mirai.exceptions.ApiError: (500, '[ERROR 500]mirai 内部错误。', 'Unsupported image type (mirai) for ExternalResource net.mamoe.mirai.internal.utils.ExternalResourceImplByFile@7b45ee21, considering use gif/png/bmp/jpg format. image header: ')
sayri23 opened this issue · 3 comments
@bot.on(GroupMessage)
def on_group_message(event: GroupMessage):
if str(event.message_chain) == '来点涩图':
setu_response = requests.get(api_setu)
setu_data = setu_response.json()
img_url = setu_data['data'][0]['urls']['original']
print(img_url)
return bot.send(event, MessageChain([Image(url=img_url), Plain('pid:'+str(setu_data['data'][0]['pid'])+'\n'+'作者:'+str(setu_data['data'][0]['author'])+'\n'+'标题:'+str(setu_data['data'][0]['title']))]))
完整log
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/mirai/utils.py", line 20, in async_with_exception
return await async_(obj)
File "/usr/local/lib/python3.10/site-packages/mirai/utils.py", line 14, in async_
return (await obj) if inspect.isawaitable(obj) else obj
File "/usr/local/lib/python3.10/site-packages/mirai/bot.py", line 407, in send
response = await send_message(
File "/usr/local/lib/python3.10/site-packages/mirai/models/api.py", line 430, in call
return await self.set(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/mirai/models/api.py", line 398, in set
return await self._call_api(
File "/usr/local/lib/python3.10/site-packages/mirai/models/api.py", line 386, in _call_api
return await api.call(self.api_provider, method, response_type)
File "/usr/local/lib/python3.10/site-packages/mirai/models/api.py", line 318, in call
raw_response = await self._call(api_provider, method)
File "/usr/local/lib/python3.10/site-packages/mirai/models/api.py", line 304, in _call
return await api_provider.call_api(
File "/usr/local/lib/python3.10/site-packages/mirai/bot.py", line 320, in call_api
return await self._adapter.call_api(api, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/mirai/adapters/websocket.py", line 236, in call_api
return await self._recv(sync_id)
File "/usr/local/lib/python3.10/site-packages/mirai/adapters/websocket.py", line 165, in _recv
raise exceptions.ApiError(data)
mirai.exceptions.ApiError: (500, '[ERROR 500]mirai 内部错误。', 'Unsupported image type (mirai) for ExternalResource net.mamoe.mirai.internal.utils.ExternalResourceImplByFile@f79bc8f, considering use gif/png/bmp/jpg format. image header: ')
试试先保存图片之后在用
Image(path=)
或者
Image(base64=)
试试
完整log
Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/mirai/utils.py", line 20, in async_with_exception return await async_(obj) File "/usr/local/lib/python3.10/site-packages/mirai/utils.py", line 14, in async_ return (await obj) if inspect.isawaitable(obj) else obj File "/usr/local/lib/python3.10/site-packages/mirai/bot.py", line 407, in send response = await send_message( File "/usr/local/lib/python3.10/site-packages/mirai/models/api.py", line 430, in call return await self.set(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/mirai/models/api.py", line 398, in set return await self._call_api( File "/usr/local/lib/python3.10/site-packages/mirai/models/api.py", line 386, in _call_api return await api.call(self.api_provider, method, response_type) File "/usr/local/lib/python3.10/site-packages/mirai/models/api.py", line 318, in call raw_response = await self._call(api_provider, method) File "/usr/local/lib/python3.10/site-packages/mirai/models/api.py", line 304, in _call return await api_provider.call_api( File "/usr/local/lib/python3.10/site-packages/mirai/bot.py", line 320, in call_api return await self._adapter.call_api(api, *args, **kwargs) File "/usr/local/lib/python3.10/site-packages/mirai/adapters/websocket.py", line 236, in call_api return await self._recv(sync_id) File "/usr/local/lib/python3.10/site-packages/mirai/adapters/websocket.py", line 165, in _recv raise exceptions.ApiError(data) mirai.exceptions.ApiError: (500, '[ERROR 500]mirai 内部错误。', 'Unsupported image type (mirai) for ExternalResource net.mamoe.mirai.internal.utils.ExternalResourceImplByFile@f79bc8f, considering use gif/png/bmp/jpg format. image header: ')
图片格式不符合规定,请检查图片的url链接是否为gif png bmp jpg当中的任何一种,如果还是有问题,请转到mirai-api-http和core上提Issue