Telethon: FilePart0Missing Error While Editing Inline Medias.

Checklist

  • The error is in the library’s code, and not in my own.
  • I have searched for this issue before posting it and there isn’t a duplicate.
  • I ran pip install -U https://github.com/LonamiWebs/Telethon/archive/master.zip and triggered the bug in the latest version.

Code that causes the issue

from telethon import TelegramClient, events, Button
client = TelegramClient("..", 1, "...").start(bot_token="...")

@client.on(events.NewMessage)
async def _(e):
  await e.reply("...", buttons=Button.inline('Click me', b'clk1'))

@client.on(events.callbackquery.CallbackQuery(data=re.compile(b"clk1")))
async def _(e):
  uploaded_file = await client.upload_file(
  		file='test.txt'
        )
  await e.edit(file=uploaded_file)

Traceback

- telethon.client.telegrambaseclient - INFO - Exporting auth for new borrowed sender in DcOption(id=2, ip_address='149.154.167.51', port=443, ipv6=False, media_only=False, tcpo_only=False, cdn=False, static=False, secret=None)
- telethon.client.uploads - INFO - Uploading file of 9781769 bytes in 75 chunks of 131072
- telethon.errors.rpcerrorlist.FilePart0MissingError: File part 0 missing (caused by EditInlineBotMessageRequest)
- telethon.client.telegrambaseclient - INFO - Disconnecting borrowed sender for DC 2
- telethon.network.mtprotosender - INFO - Disconnecting from 149.154.167.51:443/TcpFull...
- telethon.network.mtprotosender - INFO - Disconnection from 149.154.167.51:443/TcpFull complete!

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 15 (13 by maintainers)

Most upvoted comments

Editing Inline Media is already working fine for document already on Telegram. Problem is/was only for local Files.

So I just Tried

msg_media = await client.upload_file('file.txt')
media = await client(functions.messages.UploadMediaRequest(types.InputPeerSelf(), msg_media))
await event.edit(file=media)

And luckily it worked