aiogram.utils.exceptions.WrongFileIdentifier:指定了错误的文件标识符/htt



我想制作一个机器人,你可以向它发送文件链接,它会向你发送文件,但我从标题中得到一个错误。我还尝试发送InputFile对象,但没有发送任何内容。这是我的代码

from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
from aiogram.utils import executor
from aiogram.types.input_file import InputFile

bot = Bot(token = '')
dp = Dispatcher(bot)

@dp.message_handler()
async def send_playlist(message: types.Message):
print(message.text)
await bot.send_document(message.chat.id, message.text)

executor.start_polling(dp)

这是完整的错误文本

future: <Task finished name='Task-14' coro=<Dispatcher._process_polling_updates() done, defined at B:portable_softpythonlibsite-packagesaiogramdispatcherdispatcher.py:331> exception=WrongFileIdentifier('Wrong file identifier/http url specified')>
Traceback (most recent call last):
File "B:portable_softpythonlibsite-packagesaiogramdispatcherdispatcher.py", line 339, in _process_polling_updates
for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
File "B:portable_softpythonlibsite-packagesaiogramdispatcherdispatcher.py", line 194, in process_updates
return await asyncio.gather(*tasks)
File "B:portable_softpythonlibsite-packagesaiogramdispatcherhandler.py", line 117, in notify
response = await handler_obj.handler(*args, **partial_data)
File "B:portable_softpythonlibsite-packagesaiogramdispatcherdispatcher.py", line 214, in process_update
return await self.message_handlers.notify(update.message)
File "B:portable_softpythonlibsite-packagesaiogramdispatcherhandler.py", line 117, in notify
response = await handler_obj.handler(*args, **partial_data)
File "B:portable_softadbfile_bot.py", line 12, in send_playlist
await bot.send_document(message.chat.id, message.text)
File "B:portable_softpythonlibsite-packagesaiogrambotbot.py", line 402, in send_document
result = await self.request(api.Methods.SEND_DOCUMENT, payload, files)
File "B:portable_softpythonlibsite-packagesaiogrambotbase.py", line 201, in request
return await api.make_request(self.session, self.__token, method, data, files,
File "B:portable_softpythonlibsite-packagesaiogrambotapi.py", line 104, in make_request
return check_result(method, response.content_type, response.status, await response.text())
File "B:portable_softpythonlibsite-packagesaiogrambotapi.py", line 78, in check_result
exceptions.BadRequest.detect(description)
File "B:portable_softpythonlibsite-packagesaiogramutilsexceptions.py", line 136, in detect
raise err(cls.text or description)
aiogram.utils.exceptions.WrongFileIdentifier: Wrong file identifier/http url specified```

从你的问题来看,我真的不明白你想做什么。如果你能更好地描述你的用例,我可能会建议一些更有用的东西。你想用播放列表做什么?

Here is one way to work with files:
@dp.message_handler(regexp='(^cat[s]?$|puss)')
async def cats(message: types.Message):
with open('data/cats.jpg', 'rb') as photo:
'''
# Old fashioned way:
await bot.send_photo(
message.chat.id,
photo,
caption='Cats are here 😺',
reply_to_message_id=message.message_id,
)
'''
await message.reply_photo(photo, caption='Cats are here 😺')

事实上,我更喜欢使用FileID,但我不确定这是否会对你有所帮助。

嗯,只需写:

await bot.send_message(...)

但不是:

await bot.send_DOCUMENT(...)

如果弹出错误:

from aiogram import md
await bot.send_message(msg.from_user.id, md.quote_html(msg.text))

相关内容

最新更新