-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DocumentAttributeAudio ignored voice=False with io.BytesIO() object #4170
Comments
Try the Telegram voices is not an |
I checked your option, send as a file, but the telethon.tl.types.DocumentAttribute Audio attribute is ignored and is displayed in the artist column as "Unknown artist". `await client.send_file(entity=chat_id, caption="", file=img_byte_arr, force_document=True, voice_note=False, attributes=[telethon.tl.types.DocumentAttributeAudio(duration=10, title="Title", performer="Performer", voice=False)]) # Sends the audio document as needed but ignore telethon.tl.types.DocumentAttributeAudio await client.send_file(entity=chat_id, caption="", file="audio.ogg", force_document=True, voice_note=False, attributes=[telethon.tl.types.DocumentAttributeAudio(duration=10, title="Title", performer="Performer", voice=False)]) # Sends the audio document as needed but ignore telethon.tl.types.DocumentAttributeAudio` As I understand it, the voice_note flag is no longer required if the force_document=True flag is present. |
Code that causes the issue
import io
from gtts import gTTS
img_byte_arr = io.BytesIO()
tts = gTTS(text=text, lang="ru", lang_check=True)
tts.write_to_fp(img_byte_arr)
img_byte_arr.name = "name.ogg"
img_byte_arr.seek(0)
await client.send_file(entity=chat_id, caption="", file=img_byte_arr, voice_note=False, attributes=[telethon.tl.types.DocumentAttributeAudio(duration=10, title="Title", performer="Performer", voice=False)]) # Sends only a voice message ignoring voice_note=False and voice=False (bug)
await client.send_file(entity=chat_id, caption="", file="audio.mp3", voice_note=False, attributes=[telethon.tl.types.DocumentAttributeAudio(duration=10, title="Title", performer="Performer", voice=False)]) # Sends the document as needed
await client.send_file(entity=chat_id, caption="", file=img_byte_arr, voice_note=False) # Sends the document as needed
Expected behavior
Must send as a file.
Actual behavior
When sending a BytesIO() object, the parameters of sending as a file are ignored (sent only as a voice message).
If you send a file recorded on disk, then audio is sent as a file (as needed).
Traceback
No response
Telethon version
1.28.5, 1.29.2
Python version
3.7
Operating system (including distribution name and version)
Ubuntu 18.04, Windows 8.1
Other details
No response
Checklist
pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zip
and triggered the bug in the latest version.The text was updated successfully, but these errors were encountered: