From 3570953d14a9e72ddcb84154071648291f81feb4 Mon Sep 17 00:00:00 2001 From: Shrimadhav U K Date: Sat, 17 Jul 2021 00:31:08 +0530 Subject: [PATCH 1/5] Update to layer 131 (#3112) --- telethon_generator/data/api.tl | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/telethon_generator/data/api.tl b/telethon_generator/data/api.tl index 8b070368..b001ef20 100644 --- a/telethon_generator/data/api.tl +++ b/telethon_generator/data/api.tl @@ -376,6 +376,7 @@ updateChatParticipant#f3b3781f flags:# chat_id:int date:int actor_id:int user_id updateChannelParticipant#7fecb1ec flags:# channel_id:int date:int actor_id:int user_id:int prev_participant:flags.0?ChannelParticipant new_participant:flags.1?ChannelParticipant invite:flags.2?ExportedChatInvite qts:int = Update; updateBotStopped#7f9488a user_id:int date:int stopped:Bool qts:int = Update; updateGroupCallConnection#b783982 flags:# presentation:flags.0?true params:DataJSON = Update; +updateBotCommands#cf7e0873 peer:Peer bot_id:int commands:Vector = Update; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; @@ -534,7 +535,7 @@ authorization#ad01d61d flags:# current:flags.0?true official_app:flags.1?true pa account.authorizations#1250abde authorizations:Vector = account.Authorizations; -account.password#ad2641f8 flags:# has_recovery:flags.0?true has_secure_values:flags.1?true has_password:flags.2?true current_algo:flags.2?PasswordKdfAlgo srp_B:flags.2?bytes srp_id:flags.2?long hint:flags.3?string email_unconfirmed_pattern:flags.4?string new_algo:PasswordKdfAlgo new_secure_algo:SecurePasswordKdfAlgo secure_random:bytes = account.Password; +account.password#185b184f flags:# has_recovery:flags.0?true has_secure_values:flags.1?true has_password:flags.2?true current_algo:flags.2?PasswordKdfAlgo srp_B:flags.2?bytes srp_id:flags.2?long hint:flags.3?string email_unconfirmed_pattern:flags.4?string new_algo:PasswordKdfAlgo new_secure_algo:SecurePasswordKdfAlgo secure_random:bytes pending_reset_date:flags.5?int = account.Password; account.passwordSettings#9a5c33e5 flags:# email:flags.0?string secure_settings:flags.1?SecureSecretSettings = account.PasswordSettings; @@ -1205,7 +1206,7 @@ peerBlocked#e8fd8014 peer_id:Peer date:int = PeerBlocked; stats.messageStats#8999f295 views_graph:StatsGraph = stats.MessageStats; groupCallDiscarded#7780bcb4 id:long access_hash:long duration:int = GroupCall; -groupCall#653dbaad flags:# join_muted:flags.1?true can_change_join_muted:flags.2?true join_date_asc:flags.6?true schedule_start_subscribed:flags.8?true can_start_video:flags.9?true id:long access_hash:long participants_count:int title:flags.3?string stream_dc_id:flags.4?int record_start_date:flags.5?int schedule_date:flags.7?int version:int = GroupCall; +groupCall#d597650c flags:# join_muted:flags.1?true can_change_join_muted:flags.2?true join_date_asc:flags.6?true schedule_start_subscribed:flags.8?true can_start_video:flags.9?true id:long access_hash:long participants_count:int title:flags.3?string stream_dc_id:flags.4?int record_start_date:flags.5?int schedule_date:flags.7?int unmuted_video_count:flags.10?int unmuted_video_limit:int version:int = GroupCall; inputGroupCall#d8aa840f id:long access_hash:long = InputGroupCall; @@ -1248,7 +1249,7 @@ phone.exportedGroupCallInvite#204bd158 link:string = phone.ExportedGroupCallInvi groupCallParticipantVideoSourceGroup#dcb118b7 semantics:string sources:Vector = GroupCallParticipantVideoSourceGroup; -groupCallParticipantVideo#78e41663 flags:# paused:flags.0?true endpoint:string source_groups:Vector = GroupCallParticipantVideo; +groupCallParticipantVideo#67753ac8 flags:# paused:flags.0?true endpoint:string source_groups:Vector audio_source:flags.1?int = GroupCallParticipantVideo; stickers.suggestedShortName#85fea03f short_name:string = stickers.SuggestedShortName; @@ -1260,6 +1261,10 @@ botCommandScopePeer#db9d897d peer:InputPeer = BotCommandScope; botCommandScopePeerAdmins#3fd863d1 peer:InputPeer = BotCommandScope; botCommandScopePeerUser#a1321f3 peer:InputPeer user_id:InputUser = BotCommandScope; +account.resetPasswordFailedWait#e3779861 retry_date:int = account.ResetPasswordResult; +account.resetPasswordRequestedWait#e9effc7d until_date:int = account.ResetPasswordResult; +account.resetPasswordOk#e926d63e = account.ResetPasswordResult; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1281,13 +1286,14 @@ auth.bindTempAuthKey#cdd42a05 perm_auth_key_id:long nonce:long expires_at:int en auth.importBotAuthorization#67a3ff2c flags:int api_id:int api_hash:string bot_auth_token:string = auth.Authorization; auth.checkPassword#d18b4d16 password:InputCheckPasswordSRP = auth.Authorization; auth.requestPasswordRecovery#d897bc66 = auth.PasswordRecovery; -auth.recoverPassword#4ea56e92 code:string = auth.Authorization; +auth.recoverPassword#37096c70 flags:# code:string new_settings:flags.0?account.PasswordInputSettings = auth.Authorization; auth.resendCode#3ef1a9bf phone_number:string phone_code_hash:string = auth.SentCode; auth.cancelCode#1f040578 phone_number:string phone_code_hash:string = Bool; auth.dropTempAuthKeys#8e48a188 except_auth_keys:Vector = Bool; auth.exportLoginToken#b1b41517 api_id:int api_hash:string except_ids:Vector = auth.LoginToken; auth.importLoginToken#95ac5ce4 token:bytes = auth.LoginToken; auth.acceptLoginToken#e894ad4d token:bytes = Authorization; +auth.checkRecoveryPassword#d36bf79 code:string = Bool; account.registerDevice#68976c6f flags:# no_muted:flags.0?true token_type:int token:string app_sandbox:Bool secret:bytes other_uids:Vector = Bool; account.unregisterDevice#3076c4bf token_type:int token:string other_uids:Vector = Bool; @@ -1357,6 +1363,8 @@ account.getMultiWallPapers#65ad71dc wallpapers:Vector = Vector = Vector; users.getFullUser#ca30a5b1 id:InputUser = UserFull; @@ -1670,4 +1678,4 @@ stats.getMegagroupStats#dcdf8607 flags:# dark:flags.0?true channel:InputChannel stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats; -// LAYER 130 +// LAYER 131 From 79866750d257756de4247b4f3e38a27ec14f1d3b Mon Sep 17 00:00:00 2001 From: Devesh Pal <69723581+New-dev0@users.noreply.github.com> Date: Wed, 21 Jul 2021 02:34:09 +0530 Subject: [PATCH 2/5] Add new known RPCErrors (#3114) --- telethon_generator/data/errors.csv | 4 ++++ telethon_generator/data/methods.csv | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/telethon_generator/data/errors.csv b/telethon_generator/data/errors.csv index 26d4c774..498006b9 100644 --- a/telethon_generator/data/errors.csv +++ b/telethon_generator/data/errors.csv @@ -175,6 +175,7 @@ INTERDC_X_CALL_RICH_ERROR,500,A rich error occurred while communicating with DC INVITE_HASH_EMPTY,400,The invite hash is empty INVITE_HASH_EXPIRED,400,The chat the user tried to join has expired and is not valid anymore INVITE_HASH_INVALID,400,The invite hash is invalid +LANG_CODE_INVALID,400, LANG_PACK_INVALID,400,The provided language pack is invalid LASTNAME_INVALID,400,The last name is invalid LIMIT_INVALID,400,An invalid limit was provided. See https://core.telegram.org/api/files#downloading-files @@ -229,6 +230,7 @@ PARTICIPANT_VERSION_OUTDATED,400,The other participant does not use an up to dat PASSWORD_EMPTY,400,The provided password is empty PASSWORD_HASH_INVALID,400,The password (and thus its hash value) you entered is invalid PASSWORD_MISSING,400,The account must have 2-factor authentication enabled (a password) before this method can be used +PASSWORD_RECOVERY_EXPIRED,400, PASSWORD_REQUIRED,400,The account must have 2-factor authentication enabled (a password) before this method can be used PASSWORD_TOO_FRESH_X,400,The password was added too recently and {seconds} seconds must pass before using the method PAYMENT_PROVIDER_INVALID,400,The payment provider was not recognised or its token was invalid @@ -289,6 +291,7 @@ REG_ID_GENERATE_FAILED,500,Failure while generating registration ID REPLY_MARKUP_GAME_EMPTY,400,The provided reply markup for the game is empty REPLY_MARKUP_INVALID,400,The provided reply markup is invalid REPLY_MARKUP_TOO_LONG,400,The data embedded in the reply markup buttons was too much +RESET_REQUEST_MISSING,400, RESULTS_TOO_MUCH,400,"You sent too many results, see https://core.telegram.org/bots/api#answerinlinequery for the current limit" RESULT_ID_DUPLICATE,400,Duplicated IDs on the sent results. Make sure to use unique IDs RESULT_ID_INVALID,400,The given result cannot be used to send the selection to the bot @@ -313,6 +316,7 @@ SESSION_REVOKED,401,"The authorization has been invalidated, because of the user SESSION_TOO_FRESH_X,400,The session logged in too recently and {seconds} seconds must pass before calling the method SHA256_HASH_INVALID,400,The provided SHA256 hash is invalid SHORTNAME_OCCUPY_FAILED,400,An error occurred when trying to register the short-name used for the sticker pack. Try a different name +SHORT_NAME_INVALID,400, SHORT_NAME_OCCUPIED,400, SLOWMODE_WAIT_X,420,A wait of {seconds} seconds is required before sending another message in this chat SRP_ID_INVALID,400, diff --git a/telethon_generator/data/methods.csv b/telethon_generator/data/methods.csv index 72900127..9e92a452 100644 --- a/telethon_generator/data/methods.csv +++ b/telethon_generator/data/methods.csv @@ -6,6 +6,7 @@ account.checkUsername,user,USERNAME_INVALID account.confirmPasswordEmail,user, account.confirmPhone,user,CODE_HASH_INVALID PHONE_CODE_EMPTY account.createTheme,user,THEME_MIME_INVALID +account.declinePasswordReset,user,RESET_REQUEST_MISSING account.deleteAccount,user,2FA_CONFIRM_WAIT_X account.deleteSecureValue,user, account.finishTakeoutSession,user, @@ -69,6 +70,7 @@ auth.acceptLoginToken,user, auth.bindTempAuthKey,both,ENCRYPTED_MESSAGE_INVALID INPUT_REQUEST_TOO_LONG TEMP_AUTH_KEY_EMPTY TIMEOUT auth.cancelCode,user,PHONE_NUMBER_INVALID auth.checkPassword,user,PASSWORD_HASH_INVALID +auth.checkRecoveryPassword,user,PASSWORD_RECOVERY_EXPIRED auth.dropTempAuthKeys,both, auth.exportAuthorization,both,DC_ID_INVALID auth.exportLoginToken,user, @@ -76,7 +78,7 @@ auth.importAuthorization,both,AUTH_BYTES_INVALID USER_ID_INVALID auth.importBotAuthorization,both,ACCESS_TOKEN_EXPIRED ACCESS_TOKEN_INVALID API_ID_INVALID auth.importLoginToken,user,AUTH_TOKEN_ALREADY_ACCEPTED AUTH_TOKEN_EXPIRED AUTH_TOKEN_INVALID auth.logOut,both, -auth.recoverPassword,user,CODE_EMPTY +auth.recoverPassword,user,CODE_EMPTY NEW_SETTINGS_INVALID auth.requestPasswordRecovery,user,PASSWORD_EMPTY auth.resendCode,user,PHONE_NUMBER_INVALID auth.resetAuthorizations,user,TIMEOUT @@ -85,7 +87,7 @@ auth.signIn,user,PHONE_CODE_EMPTY PHONE_CODE_EXPIRED PHONE_CODE_INVALID PHONE_NU auth.signUp,user,FIRSTNAME_INVALID MEMBER_OCCUPY_PRIMARY_LOC_FAILED PHONE_CODE_EMPTY PHONE_CODE_EXPIRED PHONE_CODE_INVALID PHONE_NUMBER_FLOOD PHONE_NUMBER_INVALID PHONE_NUMBER_OCCUPIED REG_ID_GENERATE_FAILED bots.answerWebhookJSONQuery,bot,QUERY_ID_INVALID USER_BOT_INVALID bots.sendCustomRequest,bot,USER_BOT_INVALID -bots.setBotCommands,bot,BOT_COMMAND_DESCRIPTION_INVALID BOT_COMMAND_INVALID +bots.setBotCommands,bot,BOT_COMMAND_DESCRIPTION_INVALID BOT_COMMAND_INVALID LANG_CODE_INVALID channels.checkUsername,user,CHANNEL_INVALID CHAT_ID_INVALID USERNAME_INVALID channels.createChannel,user,CHAT_TITLE_EMPTY USER_RESTRICTED channels.deleteChannel,user,CHANNEL_INVALID CHANNEL_PRIVATE @@ -336,7 +338,7 @@ stats.getMegagroupStats,user,CHAT_ADMIN_REQUIRED MEGAGROUP_REQUIRED STATS_MIGRAT stats.loadAsyncGraph,user,GRAPH_INVALID_RELOAD GRAPH_OUTDATED_RELOAD stickers.addStickerToSet,bot,BOT_MISSING STICKERSET_INVALID STICKER_PNG_NOPNG STICKER_TGS_NOTGS stickers.changeStickerPosition,bot,BOT_MISSING STICKER_INVALID -stickers.checkShortName,both,SHORT_NAME_OCCUPIED +stickers.checkShortName,both,SHORT_NAME_INVALID SHORT_NAME_OCCUPIED stickers.createStickerSet,bot,BOT_MISSING PACK_SHORT_NAME_INVALID PACK_SHORT_NAME_OCCUPIED PEER_ID_INVALID SHORTNAME_OCCUPY_FAILED STICKERS_EMPTY STICKER_EMOJI_INVALID STICKER_FILE_INVALID STICKER_PNG_DIMENSIONS STICKER_PNG_NOPNG STICKER_TGS_NOTGS STICKER_THUMB_PNG_NOPNG STICKER_THUMB_TGS_NOTGS USER_ID_INVALID stickers.removeStickerFromSet,bot,BOT_MISSING STICKER_INVALID stickers.setStickerSetThumb,bot,STICKER_THUMB_PNG_NOPNG STICKER_THUMB_TGS_NOTGS From e2d97b44c59a05980c530604cfd1ca7e370ebdc0 Mon Sep 17 00:00:00 2001 From: Joshua Coales Date: Tue, 3 Aug 2021 17:33:17 +0100 Subject: [PATCH 3/5] Update docs to have fewer grammatical mistakes (#3121) --- readthedocs/concepts/botapi-vs-mtproto.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs/concepts/botapi-vs-mtproto.rst b/readthedocs/concepts/botapi-vs-mtproto.rst index cddb52d0..224bca08 100644 --- a/readthedocs/concepts/botapi-vs-mtproto.rst +++ b/readthedocs/concepts/botapi-vs-mtproto.rst @@ -145,7 +145,7 @@ After using Telethon: Key differences: -* The recommended way to do it imports less things. +* The recommended way to do it imports fewer things. * All handlers trigger by default, so we need ``events.StopPropagation``. * Adding handlers, responding and running is a lot less verbose. * Telethon needs ``async def`` and ``await``. From 196cef66fd55184cab9704e2687a401db3cc2d7d Mon Sep 17 00:00:00 2001 From: alexkoay Date: Wed, 4 Aug 2021 00:33:46 +0800 Subject: [PATCH 4/5] Fix typehint for callback in UpdateMethods (#3119) --- telethon/client/updates.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/telethon/client/updates.py b/telethon/client/updates.py index a9d6344e..5bdf5893 100644 --- a/telethon/client/updates.py +++ b/telethon/client/updates.py @@ -16,6 +16,8 @@ if typing.TYPE_CHECKING: from .telegramclient import TelegramClient +Callback = typing.Callable[[typing.Any], typing.Any] + class UpdateMethods: # region Public methods @@ -104,7 +106,7 @@ class UpdateMethods: def add_event_handler( self: 'TelegramClient', - callback: callable, + callback: Callback, event: EventBuilder = None): """ Registers a new event handler callback. @@ -153,7 +155,7 @@ class UpdateMethods: def remove_event_handler( self: 'TelegramClient', - callback: callable, + callback: Callback, event: EventBuilder = None) -> int: """ Inverse operation of `add_event_handler()`. @@ -191,7 +193,7 @@ class UpdateMethods: return found def list_event_handlers(self: 'TelegramClient')\ - -> 'typing.Sequence[typing.Tuple[callable, EventBuilder]]': + -> 'typing.Sequence[typing.Tuple[Callback, EventBuilder]]': """ Lists all registered event handlers. From ad55b945c1dff0dbeab226b00301cb4ef634d5bb Mon Sep 17 00:00:00 2001 From: Devesh Pal Date: Tue, 3 Aug 2021 22:04:10 +0530 Subject: [PATCH 5/5] Add comment_to to InlineResult-click method (#3118) --- telethon/tl/custom/inlineresult.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/telethon/tl/custom/inlineresult.py b/telethon/tl/custom/inlineresult.py index f189068c..97493281 100644 --- a/telethon/tl/custom/inlineresult.py +++ b/telethon/tl/custom/inlineresult.py @@ -102,7 +102,7 @@ class InlineResult: elif isinstance(self.result, types.BotInlineMediaResult): return self.result.document - async def click(self, entity=None, reply_to=None, + async def click(self, entity=None, reply_to=None, comment_to=None, silent=False, clear_draft=False, hide_via=False): """ Clicks this result and sends the associated `message`. @@ -114,6 +114,11 @@ class InlineResult: reply_to (`int` | `Message `, optional): If present, the sent message will reply to this ID or message. + comment_to (`int` | `Message `, optional): + Similar to ``reply_to``, but replies in the linked group of a + broadcast channel instead (effectively leaving a "comment to" + the specified message). + silent (`bool`, optional): Whether the message should notify people with sound or not. Defaults to `False` (send with a notification sound unless @@ -135,7 +140,11 @@ class InlineResult: else: raise ValueError('You must provide the entity where the result should be sent to') - reply_id = None if reply_to is None else utils.get_message_id(reply_to) + if comment_to: + entity, reply_id = await self._client._get_comment_data(entity, comment_to) + else: + reply_id = None if reply_to is None else utils.get_message_id(reply_to) + req = functions.messages.SendInlineBotResultRequest( peer=entity, query_id=self._query_id,