From 4393ec0b83d511b6a20d8a20334138730f084375 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Tue, 5 May 2020 09:28:37 +0200 Subject: [PATCH] Support dice autocast and update docs on send_file for dice --- telethon/client/uploads.py | 17 +++++++++++++++++ telethon/utils.py | 3 +++ 2 files changed, 20 insertions(+) diff --git a/telethon/client/uploads.py b/telethon/client/uploads.py index fb924595..c8564ad1 100644 --- a/telethon/client/uploads.py +++ b/telethon/client/uploads.py @@ -155,6 +155,10 @@ class UploadMethods: * 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. If a list or similar is provided, the files in it will be @@ -270,6 +274,19 @@ class UploadMethods: 'bytes: {:.2%}'.format(current / total)) 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 # i.e. `None` was used diff --git a/telethon/utils.py b/telethon/utils.py index 95bb65aa..b00644ca 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -512,6 +512,9 @@ def get_input_media( venue_type='' ) + if isinstance(media, types.MessageMediaDice): + return types.InputMediaDice(media.emoticon) + if isinstance(media, ( types.MessageMediaEmpty, types.MessageMediaUnsupported, types.ChatPhotoEmpty, types.UserProfilePhotoEmpty,