Support dice autocast and update docs on send_file for dice

This commit is contained in:
Lonami Exo 2020-05-05 09:28:37 +02:00
parent db16cf5548
commit 4393ec0b83
2 changed files with 20 additions and 0 deletions

View File

@ -155,6 +155,10 @@ class UploadMethods:
* A handle to an uploaded file (from `upload_file`). * A handle to an uploaded file (from `upload_file`).
* A :tl:`InputMedia` instance. For example, if you want to
send a dice use :tl:`InputMediaDice`, or if you want to
send a contact use :tl:`InputMediaContact`.
To send an album, you should provide a list in this parameter. To send an album, you should provide a list in this parameter.
If a list or similar is provided, the files in it will be If a list or similar is provided, the files in it will be
@ -270,6 +274,19 @@ class UploadMethods:
'bytes: {:.2%}'.format(current / total)) 'bytes: {:.2%}'.format(current / total))
await client.send_file(chat, file, progress_callback=callback) await client.send_file(chat, file, progress_callback=callback)
# Dices, including dart and other future emoji
from telethon.tl import types
await client.send_file(chat, types.InputMediaDice(''))
await client.send_file(chat, types.InputMediaDice('🎯'))
# Contacts
await client.send_file(chat, types.InputMediaContact(
phone_number='+34 123 456 789',
first_name='Example',
last_name='',
vcard=''
))
""" """
# TODO Properly implement allow_cache to reuse the sha256 of the file # TODO Properly implement allow_cache to reuse the sha256 of the file
# i.e. `None` was used # i.e. `None` was used

View File

@ -512,6 +512,9 @@ def get_input_media(
venue_type='' venue_type=''
) )
if isinstance(media, types.MessageMediaDice):
return types.InputMediaDice(media.emoticon)
if isinstance(media, ( if isinstance(media, (
types.MessageMediaEmpty, types.MessageMediaUnsupported, types.MessageMediaEmpty, types.MessageMediaUnsupported,
types.ChatPhotoEmpty, types.UserProfilePhotoEmpty, types.ChatPhotoEmpty, types.UserProfilePhotoEmpty,