LonamiWebs / Telethon

Pure Python 3 MTProto API Telegram client library, for bots too!
https://docs.telethon.dev
MIT License
10.06k stars 1.41k forks source link

MessageMediaPoll object could not be forwarded #3043

Closed aahnik closed 3 years ago

aahnik commented 3 years ago

Checklist

related to https://github.com/aahnik/tgcf/issues/50

Code that caused the issue

client.send_message() caused it. The message had a poll object.

Traceback

File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/tgcf/utils.py", line 8, in send_message
    return await client.send_message(*args)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/telethon/client/messages.py", line 782, in send_message
    return await self.send_file(
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/telethon/client/uploads.py", line 386, in send_file
    raise TypeError('Cannot use {!r} as file'.format(file))
TypeError: Cannot use <telethon.tl.types.MessageMediaPoll object at 0x713713a700> as file

This error was found while running my program on Termux. (android)

I did not find this error on my computer (Ubuntu 20.04)

python version 3.9 used.

telethon version 1.21.1

Lonami commented 3 years ago

You cannot resend copies of polls because all the data isn't known until you actually choose an option. While it could work then, it's strange it would "works sometimes but not others", so closing.

aahnik commented 3 years ago

@Lonami, after little more experimentation,

a poll in quiz mode can be forwarded by hand in the telegram app. so why can't it be forwarded programmatically?

I think it is some bug with Telethon.

https://github.com/LonamiWebs/Telethon/blob/b2c26a53efe25110d32aef7d0f675089d8d1a77b/telethon/client/uploads.py#L385-L386

seems like a poll with quiz mode is not supported in telethon

Lonami commented 3 years ago

Yes, you can forward polls just fine (forward_messages). What you can't do is resend them as copies reliably (send_message).