首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >aiogram.utils.exceptions.WrongFileIdentifier:指定的文件标识符/http url错误

aiogram.utils.exceptions.WrongFileIdentifier:指定的文件标识符/http url错误
EN

Stack Overflow用户
提问于 2020-07-30 14:44:58
回答 1查看 325关注 0票数 0

我想做一个机器人,你向它发送一个指向文件的链接,它会把文件发送给你,但我从头文件中得到了一个错误。我也尝试发送InputFile对象,但没有发送任何内容。这是我的代码

代码语言:javascript
复制
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)

下面是完整的错误文本

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

回答 1

Stack Overflow用户

发布于 2021-02-10 06:23:18

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

代码语言:javascript
复制
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,但我不确定这是否会对您有所帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63167591

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档