From 39e899294f1c863f33680689d2a2ad1ffaf262fd Mon Sep 17 00:00:00 2001 From: vegeta1k95 <32207817+vegeta1k95@users.noreply.github.com> Date: Wed, 4 Nov 2020 09:58:20 +0100 Subject: [PATCH 1/9] Fix unhandled ValueError inside _dispatch_update() task (#1615) --- telethon/client/updates.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/telethon/client/updates.py b/telethon/client/updates.py index 4a9c2d4b..2c2b2836 100644 --- a/telethon/client/updates.py +++ b/telethon/client/updates.py @@ -397,6 +397,11 @@ class UpdateMethods: # the channel. Because these "happen sporadically" (#1428) # we should be okay (no flood waits) even if more occur. pass + except ValueError: + # There is a chance that GetFullChannelRequest and GetDifferenceRequest + # inside the _get_difference() function will end up with + # ValueError("Request was unsuccessful N time(s)") for whatever reasons. + pass if not self._self_input_peer: # Some updates require our own ID, so we must make sure From b6fe4b8fec0c405c831fefdb3766b9ab8e5d0661 Mon Sep 17 00:00:00 2001 From: hematogender <46577620+hematogender@users.noreply.github.com> Date: Wed, 4 Nov 2020 21:28:04 +0200 Subject: [PATCH 2/9] Fix get_display_name not handling ChatForbidden (#1617) Closes #1616. --- telethon/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telethon/utils.py b/telethon/utils.py index 18723dc7..e9c1468d 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -102,7 +102,7 @@ def get_display_name(entity): else: return '' - elif isinstance(entity, (types.Chat, types.Channel)): + elif isinstance(entity, (types.Chat, types.ChatForbidden, types.Channel)): return entity.title return '' From 78514110de7d0790b0a06cb1a5e5b20665a290fd Mon Sep 17 00:00:00 2001 From: x0x8x <5467132+x0x8x@users.noreply.github.com> Date: Thu, 5 Nov 2020 12:40:44 +0300 Subject: [PATCH 3/9] Update errors.csv (#1609) --- telethon_generator/data/errors.csv | 54 +++++++++++++++++++----------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/telethon_generator/data/errors.csv b/telethon_generator/data/errors.csv index b90e9a8a..ed40e0b8 100644 --- a/telethon_generator/data/errors.csv +++ b/telethon_generator/data/errors.csv @@ -6,6 +6,7 @@ ACTIVE_USER_REQUIRED,401,The method is only available to already activated users ADMINS_TOO_MUCH,400,Too many admins ADMIN_RANK_EMOJI_NOT_ALLOWED,400,Emoji are not allowed in admin titles or ranks ADMIN_RANK_INVALID,400,The given admin title or rank was invalid (possibly larger than 16 characters) +ALBUM_PHOTOS_TOO_MANY,400,Too many photos were included in the album API_ID_INVALID,400,The api_id/api_hash combination is invalid API_ID_PUBLISHED_FLOOD,400,"This API id was published somewhere, you can't use it now" ARTICLE_TITLE_EMPTY,400,The title of the article is empty @@ -19,6 +20,8 @@ AUTH_RESTART,500,Restart the authorization process AUTH_TOKEN_ALREADY_ACCEPTED,400,The authorization token was already used AUTH_TOKEN_EXPIRED,400,The provided authorization token has expired and the updated QR-code must be re-scanned AUTH_TOKEN_INVALID,400,An invalid authorization token was provided +AUTOARCHIVE_NOT_AVAILABLE,400,You cannot use this feature yet +BANK_CARD_NUMBER_INVALID,400,Incorrect credit card number BANNED_RIGHTS_INVALID,400,"You cannot use that set of permissions in this request, i.e. restricting view_messages as a default" BOTS_TOO_MUCH,400,There are too many bots in this chat/channel BOT_CHANNELS_NA,400,Bots can't edit admin privileges @@ -48,14 +51,15 @@ CALL_PROTOCOL_FLAGS_INVALID,400,Call protocol flags invalid CDN_METHOD_INVALID,400,This method cannot be invoked on a CDN server. Refer to https://core.telegram.org/cdn#schema for available methods CHANNELS_ADMIN_PUBLIC_TOO_MUCH,400,"You're admin of too many public channels, make some channels private to change the username of this channel" CHANNELS_TOO_MUCH,400,You have joined too many channels/supergroups +CHANNEL_BANNED,400,The channel is banned CHANNEL_INVALID,400,"Invalid channel object. Make sure to pass the right types, for instance making sure that the request is designed for channels or otherwise look for a different one more suited" CHANNEL_PRIVATE,400,The channel specified is private and you lack permission to access it. Another reason may be that you were banned from it CHANNEL_PUBLIC_GROUP_NA,403,channel/supergroup not available CHAT_ABOUT_NOT_MODIFIED,400,About text has not changed CHAT_ABOUT_TOO_LONG,400,Chat about too long CHAT_ADMIN_INVITE_REQUIRED,403,You do not have the rights to do this -CHAT_ADMIN_REQUIRED,400 403,"Chat admin privileges are required to do that in the specified chat (for example, to send a message in a channel which is not yours), or invalid permissions used for the channel or group" -CHAT_FORBIDDEN,,You cannot write in this chat +CHAT_ADMIN_REQUIRED,400,"Chat admin privileges are required to do that in the specified chat (for example, to send a message in a channel which is not yours), or invalid permissions used for the channel or group" +CHAT_FORBIDDEN,403,You cannot write in this chat CHAT_ID_EMPTY,400,The provided chat ID is empty CHAT_ID_INVALID,400,"Invalid object ID for a chat. Make sure to pass the right types, for instance making sure that the request is designed for chats (not channels/megagroups) or otherwise look for a different one more suited\nAn example working with a megagroup and AddChatUserRequest, it will fail because megagroups are channels. Use InviteToChannelRequest instead" CHAT_INVALID,400,The chat is invalid for this request @@ -85,6 +89,7 @@ DATA_JSON_INVALID,400,The provided JSON data is invalid DATE_EMPTY,400,Date empty DC_ID_INVALID,400,This occurs when an authorization is tried to be exported for the same data center one is currently connected to DH_G_A_INVALID,400,g_a invalid +DOCUMENT_INVALID,400,The document file was invalid and can't be used in inline mode EMAIL_HASH_EXPIRED,400,The email hash expired and cannot be used to verify it EMAIL_INVALID,400,The given email is invalid EMAIL_UNCONFIRMED_X,400,"Email unconfirmed, the length of the code must be {code_length}" @@ -102,12 +107,13 @@ ENTITY_MENTION_USER_INVALID,400,You can't use this entity ERROR_TEXT_EMPTY,400,The provided error message is empty EXPORT_CARD_INVALID,400,Provided card is invalid EXTERNAL_URL_INVALID,400,External URL invalid -FIELD_NAME_EMPTY,,The field with the name FIELD_NAME is missing -FIELD_NAME_INVALID,,The field with the name FIELD_NAME is invalid +FIELD_NAME_EMPTY,400,The field with the name FIELD_NAME is missing +FIELD_NAME_INVALID,400,The field with the name FIELD_NAME is invalid +FILEREF_UPGRADE_NEEDED,406,The file reference needs to be refreshed before being used again FILE_ID_INVALID,400,"The provided file id is invalid. Make sure all parameters are present, have the correct type and are not empty (ID, access hash, file reference, thumb size ...)" FILE_MIGRATE_X,303,The file to be accessed is currently stored in DC {new_dc} FILE_PARTS_INVALID,400,The number of file parts is invalid -FILE_PART_0_MISSING,,File part 0 missing +FILE_PART_0_MISSING,400,File part 0 missing FILE_PART_EMPTY,400,The provided file part is empty FILE_PART_INVALID,400,The file part number is invalid FILE_PART_LENGTH_INVALID,400,The length of a file part is invalid @@ -116,7 +122,7 @@ FILE_PART_SIZE_INVALID,400,The provided file part size is invalid FILE_PART_X_MISSING,400,Part {which} of the file is missing from storage FILE_REFERENCE_EMPTY,400,The file reference must exist to access the media and it cannot be empty FILE_REFERENCE_EXPIRED,400,The file reference has expired and is no longer valid or it belongs to self-destructing media and cannot be resent -FILEREF_UPGRADE_NEEDED,406,The file reference needs to be refreshed before being used again +FILE_REFERENCE_INVALID,400,The file reference is invalid or you can't do that operation on such message FIRSTNAME_INVALID,400,The first name is invalid FLOOD_TEST_PHONE_WAIT_X,420,A wait of {seconds} seconds is required in the test servers FLOOD_WAIT_X,420,A wait of {seconds} seconds is required @@ -127,6 +133,7 @@ FRESH_CHANGE_PHONE_FORBIDDEN,406,Recently logged-in users cannot use this reques FRESH_RESET_AUTHORISATION_FORBIDDEN,406,The current session is too new and cannot be used to reset other authorisations yet GAME_BOT_INVALID,400,You cannot send that game with the current bot GIF_ID_INVALID,400,The provided GIF ID is invalid +GRAPH_OUTDATED_RELOAD,400,Data can't be used for the channel statistics, graphs outdated GROUPED_MEDIA_INVALID,400,Invalid grouped media HASH_INVALID,400,The provided hash is invalid HISTORY_GET_FAILED,500,Fetching of history failed @@ -134,25 +141,26 @@ IMAGE_PROCESS_FAILED,400,Failure while processing image INLINE_BOT_REQUIRED,403,The action must be performed through an inline bot callback INLINE_RESULT_EXPIRED,400,The inline query expired INPUT_CONSTRUCTOR_INVALID,400,The provided constructor is invalid -INPUT_FETCH_ERROR,,An error occurred while deserializing TL parameters +INPUT_FETCH_ERROR,400,An error occurred while deserializing TL parameters INPUT_FETCH_FAIL,400,Failed deserializing TL payload +INPUT_FILTER_INVALID,400,The search query filter is valid INPUT_LAYER_INVALID,400,The provided layer is invalid -INPUT_METHOD_INVALID,,The invoked method does not exist anymore or has never existed +INPUT_METHOD_INVALID,400,The invoked method does not exist anymore or has never existed INPUT_REQUEST_TOO_LONG,400,The input request was too long. This may be a bug in the library as it can occur when serializing more bytes than it should (like appending the vector constructor code at the end of a message) INPUT_USER_DEACTIVATED,400,The specified user was deleted -INTERDC_X_CALL_ERROR,,An error occurred while communicating with DC {dc} -INTERDC_X_CALL_RICH_ERROR,,A rich error occurred while communicating with DC {dc} +INTERDC_X_CALL_ERROR,500,An error occurred while communicating with DC {dc} +INTERDC_X_CALL_RICH_ERROR,500,A rich error occurred while communicating with DC {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_PACK_INVALID,400,The provided language pack is invalid -LASTNAME_INVALID,,The last name 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 LINK_NOT_MODIFIED,400,The channel is already linked to this group LOCATION_INVALID,400,The location given for a file was invalid. See https://core.telegram.org/api/files#downloading-files MAX_ID_INVALID,400,The provided max ID is invalid MAX_QTS_INVALID,400,The provided QTS were invalid -MD5_CHECKSUM_INVALID,,The MD5 check-sums do not match +MD5_CHECKSUM_INVALID,400,The MD5 check-sums do not match MEDIA_CAPTION_TOO_LONG,400,The caption is too long MEDIA_EMPTY,400,The provided media object is invalid or the current account may not be able to send it (such as games as users) MEDIA_INVALID,400,Media invalid @@ -177,6 +185,7 @@ MSGID_DECREASE_RETRY,500,The request should be retried with a lower message ID MSG_ID_INVALID,400,The message ID used in the peer was invalid MSG_WAIT_FAILED,400,A waiting call returned an error MT_SEND_QUEUE_TOO_LONG,500, +MULTI_MEDIA_TOO_LONG,400,Too many media files were included in the same album NEED_CHAT_INVALID,500,The provided chat is invalid NEED_MEMBER_INVALID,500,The provided member is invalid or does not exist (for example a thumb size) NETWORK_MIGRATE_X,303,The source IP address is associated with DC {new_dc} @@ -184,8 +193,8 @@ NEW_SALT_INVALID,400,The new salt is invalid NEW_SETTINGS_INVALID,400,The new settings are invalid OFFSET_INVALID,400,"The given offset was invalid, it must be divisible by 1KB. See https://core.telegram.org/api/files#downloading-files" OFFSET_PEER_ID_INVALID,400,The provided offset peer is invalid -OPTION_INVALID,400,The option specified is invalid and does not exist in the target poll OPTIONS_TOO_MUCH,400,You defined too many options for the poll +OPTION_INVALID,400,The option specified is invalid and does not exist in the target poll PACK_SHORT_NAME_INVALID,400,"Invalid sticker pack name. It must begin with a letter, can't contain consecutive underscores and must end in ""_by_""." PACK_SHORT_NAME_OCCUPIED,400,A stickerpack with this name already exists PARTICIPANTS_TOO_FEW,400,Not enough participants @@ -197,7 +206,7 @@ PASSWORD_MISSING,400,The account must have 2-factor authentication enabled (a pa 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 -PEER_FLOOD,,Too many requests +PEER_FLOOD,400,Too many requests PEER_ID_INVALID,400,"An invalid Peer was used. Make sure to pass the right peer type and that the value is valid (for instance, bots cannot start conversations)" PEER_ID_NOT_SUPPORTED,400,The provided peer ID is not supported PERSISTENT_TIMESTAMP_EMPTY,400,Persistent timestamp empty @@ -205,10 +214,10 @@ PERSISTENT_TIMESTAMP_INVALID,400,Persistent timestamp invalid PERSISTENT_TIMESTAMP_OUTDATED,500,Persistent timestamp outdated PHONE_CODE_EMPTY,400,The phone code is missing PHONE_CODE_EXPIRED,400,The confirmation code has expired -PHONE_CODE_HASH_EMPTY,,The phone code hash is missing +PHONE_CODE_HASH_EMPTY,400,The phone code hash is missing PHONE_CODE_INVALID,400,The phone code entered was invalid PHONE_MIGRATE_X,303,The phone number a user is trying to use for authorization is associated with DC {new_dc} -PHONE_NUMBER_APP_SIGNUP_FORBIDDEN,400, +PHONE_NUMBER_APP_SIGNUP_FORBIDDEN,400,You can't sign up using this app PHONE_NUMBER_BANNED,400,The used phone number has been banned from Telegram and cannot be used anymore. Maybe check https://www.telegram.org/faq_spam PHONE_NUMBER_FLOOD,400,You asked for the code too many times. PHONE_NUMBER_INVALID,400 406,The phone number is invalid @@ -219,6 +228,7 @@ PHONE_PASSWORD_PROTECTED,400,This phone is password protected PHOTO_CONTENT_URL_EMPTY,400,The content from the URL used as a photo appears to be empty or has caused another HTTP error PHOTO_CROP_SIZE_SMALL,400,Photo is too small PHOTO_EXT_INVALID,400,The extension of the photo is invalid +PHOTO_ID_INVALID,400,Photo id is invalid PHOTO_INVALID,400,Photo invalid PHOTO_INVALID_DIMENSIONS,400,The photo dimensions are invalid (hint: `pip install pillow` for `send_file` to resize images) PHOTO_SAVE_FILE_INVALID,400,The photo you tried to send cannot be saved by Telegram. A reason may be that it exceeds 10MB. Try resizing it locally @@ -231,6 +241,7 @@ POLL_QUESTION_INVALID,400,The poll question was either empty or too long POLL_UNSUPPORTED,400,This layer does not support polls in the issued method PRIVACY_KEY_INVALID,400,The privacy key is invalid PRIVACY_TOO_LONG,400,Cannot add that many entities in a single request +PRIVACY_VALUE_INVALID,400,The privacy value is invalid PTS_CHANGE_EMPTY,500,No PTS change QUERY_ID_EMPTY,400,The query ID is empty QUERY_ID_INVALID,400,The query ID is invalid @@ -246,15 +257,16 @@ RANGES_INVALID,400,Invalid range provided REACTION_EMPTY,400,No reaction provided REACTION_INVALID,400,Invalid reaction provided (only emoji are allowed) 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 +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 RESULT_TYPE_INVALID,400,Result type invalid -RESULTS_TOO_MUCH,400,You sent too many results. See https://core.telegram.org/bots/api#answerinlinequery for the current limit. RIGHT_FORBIDDEN,403,Either your admin rights do not allow you to do this or you passed the wrong rights combination (some rights only apply to channels and vice versa) -RPC_CALL_FAIL,,"Telegram is having internal issues, please try again later." -RPC_MCGET_FAIL,,"Telegram is having internal issues, please try again later." +RPC_CALL_FAIL,500,"Telegram is having internal issues, please try again later." +RPC_MCGET_FAIL,500,"Telegram is having internal issues, please try again later." RSA_DECRYPT_FAILED,400,Internal RSA decryption failed SCHEDULE_BOT_NOT_ALLOWED,400,Bots are not allowed to schedule messages SCHEDULE_DATE_TOO_LATE,400,The date you tried to schedule is too far in the future (last known limit of 1 year and a few hours) @@ -264,6 +276,7 @@ SEARCH_QUERY_EMPTY,400,The search query is empty SECONDS_INVALID,400,"Slow mode only supports certain values (e.g. 0, 10s, 30s, 1m, 5m, 15m and 1h)" SEND_MESSAGE_MEDIA_INVALID,400,The message media was invalid or not specified SEND_MESSAGE_TYPE_INVALID,400,The message type is invalid +SENSITIVE_CHANGE_FORBIDDEN,403,Your sensitive content settings cannot be changed at this time SESSION_EXPIRED,401,The authorization has expired SESSION_PASSWORD_NEEDED,401,Two-steps verification is enabled and a password is required SESSION_REVOKED,401,"The authorization has been invalidated, because of the user terminating all sessions" @@ -291,11 +304,12 @@ TAKEOUT_INVALID,400,The takeout session has been invalidated by another data exp TAKEOUT_REQUIRED,400,You must initialize a takeout request first TEMP_AUTH_KEY_EMPTY,400,No temporary auth key provided Timeout,-503,A timeout occurred while fetching data from the worker +THEME_MIME_INVALID,400,You cannot create this theme, the mime-type is invalid TMP_PASSWORD_DISABLED,400,The temporary password is disabled TOKEN_INVALID,400,The provided token is invalid TTL_DAYS_INVALID,400,The provided TTL is invalid TYPES_EMPTY,400,The types field is empty -TYPE_CONSTRUCTOR_INVALID,,The type constructor is invalid +TYPE_CONSTRUCTOR_INVALID,400,The type constructor is invalid UNKNOWN_METHOD,500,The method you tried to call cannot be called on non-CDN DCs UNTIL_DATE_INVALID,400,That date cannot be specified in this request (try using None) URL_INVALID,400,The URL used was invalid (e.g. when answering a callback with a URL that's not t.me/yourbot or your game's URL) From e4a6ec40cd0badb05d857b286507f821fcab4432 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 5 Nov 2020 10:49:34 +0100 Subject: [PATCH 4/9] Update error documentation, summary and license year --- LICENSE | 2 +- .../quick-references/client-reference.rst | 1 + telethon_generator/data/errors.csv | 8 +++---- telethon_generator/data/methods.csv | 21 ++++++++++--------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/LICENSE b/LICENSE index 7a430dd1..3f8fcce5 100755 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2016-2019 LonamiWebs +Copyright (c) 2016-2020 LonamiWebs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/readthedocs/quick-references/client-reference.rst b/readthedocs/quick-references/client-reference.rst index 91b9bfe2..2331c8d5 100644 --- a/readthedocs/quick-references/client-reference.rst +++ b/readthedocs/quick-references/client-reference.rst @@ -65,6 +65,7 @@ Messages iter_messages get_messages pin_message + unpin_message send_read_acknowledge Uploads diff --git a/telethon_generator/data/errors.csv b/telethon_generator/data/errors.csv index ed40e0b8..0641f438 100644 --- a/telethon_generator/data/errors.csv +++ b/telethon_generator/data/errors.csv @@ -6,7 +6,7 @@ ACTIVE_USER_REQUIRED,401,The method is only available to already activated users ADMINS_TOO_MUCH,400,Too many admins ADMIN_RANK_EMOJI_NOT_ALLOWED,400,Emoji are not allowed in admin titles or ranks ADMIN_RANK_INVALID,400,The given admin title or rank was invalid (possibly larger than 16 characters) -ALBUM_PHOTOS_TOO_MANY,400,Too many photos were included in the album +ALBUM_PHOTOS_TOO_MANY,400,Too many photos were included in the album API_ID_INVALID,400,The api_id/api_hash combination is invalid API_ID_PUBLISHED_FLOOD,400,"This API id was published somewhere, you can't use it now" ARTICLE_TITLE_EMPTY,400,The title of the article is empty @@ -133,7 +133,7 @@ FRESH_CHANGE_PHONE_FORBIDDEN,406,Recently logged-in users cannot use this reques FRESH_RESET_AUTHORISATION_FORBIDDEN,406,The current session is too new and cannot be used to reset other authorisations yet GAME_BOT_INVALID,400,You cannot send that game with the current bot GIF_ID_INVALID,400,The provided GIF ID is invalid -GRAPH_OUTDATED_RELOAD,400,Data can't be used for the channel statistics, graphs outdated +GRAPH_OUTDATED_RELOAD,400,"Data can't be used for the channel statistics, graphs outdated" GROUPED_MEDIA_INVALID,400,Invalid grouped media HASH_INVALID,400,The provided hash is invalid HISTORY_GET_FAILED,500,Fetching of history failed @@ -241,7 +241,7 @@ POLL_QUESTION_INVALID,400,The poll question was either empty or too long POLL_UNSUPPORTED,400,This layer does not support polls in the issued method PRIVACY_KEY_INVALID,400,The privacy key is invalid PRIVACY_TOO_LONG,400,Cannot add that many entities in a single request -PRIVACY_VALUE_INVALID,400,The privacy value is invalid +PRIVACY_VALUE_INVALID,400,The privacy value is invalid PTS_CHANGE_EMPTY,500,No PTS change QUERY_ID_EMPTY,400,The query ID is empty QUERY_ID_INVALID,400,The query ID is invalid @@ -304,7 +304,7 @@ TAKEOUT_INVALID,400,The takeout session has been invalidated by another data exp TAKEOUT_REQUIRED,400,You must initialize a takeout request first TEMP_AUTH_KEY_EMPTY,400,No temporary auth key provided Timeout,-503,A timeout occurred while fetching data from the worker -THEME_MIME_INVALID,400,You cannot create this theme, the mime-type is invalid +THEME_MIME_INVALID,400,"You cannot create this theme, the mime-type is invalid" TMP_PASSWORD_DISABLED,400,The temporary password is disabled TOKEN_INVALID,400,The provided token is invalid TTL_DAYS_INVALID,400,The provided TTL is invalid diff --git a/telethon_generator/data/methods.csv b/telethon_generator/data/methods.csv index 26e5f113..8946f542 100644 --- a/telethon_generator/data/methods.csv +++ b/telethon_generator/data/methods.csv @@ -5,7 +5,7 @@ account.changePhone,user,PHONE_NUMBER_INVALID account.checkUsername,user,USERNAME_INVALID account.confirmPasswordEmail,user, account.confirmPhone,user,CODE_HASH_INVALID PHONE_CODE_EMPTY -account.createTheme,user, +account.createTheme,user,THEME_MIME_INVALID account.deleteSecureValue,user, account.finishTakeoutSession,user, account.getAccountTTL,user, @@ -49,7 +49,8 @@ account.sendVerifyEmailCode,user,EMAIL_INVALID account.sendVerifyPhoneCode,user, account.setAccountTTL,user,TTL_DAYS_INVALID account.setContactSignUpNotification,user, -account.setContentSettings,user, +account.setContentSettings,user,SENSITIVE_CHANGE_FORBIDDEN +account.setGlobalPrivacySettings,user,AUTOARCHIVE_NOT_AVAILABLE account.setPrivacy,user,PRIVACY_KEY_INVALID PRIVACY_TOO_LONG account.unregisterDevice,user,TOKEN_INVALID account.updateDeviceLocked,user, @@ -94,7 +95,7 @@ channels.editAdmin,both,ADMINS_TOO_MUCH ADMIN_RANK_EMOJI_NOT_ALLOWED ADMIN_RANK_ channels.editBanned,both,CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED USER_ADMIN_INVALID USER_ID_INVALID channels.editCreator,user,PASSWORD_MISSING PASSWORD_TOO_FRESH_X SESSION_TOO_FRESH_X channels.editLocation,user, -channels.editPhoto,both,CHANNEL_INVALID CHAT_ADMIN_REQUIRED PHOTO_INVALID +channels.editPhoto,both,CHANNEL_INVALID CHAT_ADMIN_REQUIRED FILE_REFERENCE_INVALID PHOTO_INVALID channels.editTitle,both,CHANNEL_INVALID CHAT_ADMIN_REQUIRED CHAT_NOT_MODIFIED channels.exportMessageLink,user,CHANNEL_INVALID channels.getAdminLog,user,CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED @@ -264,7 +265,7 @@ messages.requestUrlAuth,user, messages.saveDraft,user,PEER_ID_INVALID messages.saveGif,user,GIF_ID_INVALID messages.saveRecentSticker,user,STICKER_ID_INVALID -messages.search,user,CHAT_ADMIN_REQUIRED INPUT_CONSTRUCTOR_INVALID INPUT_USER_DEACTIVATED PEER_ID_INVALID PEER_ID_NOT_SUPPORTED SEARCH_QUERY_EMPTY USER_ID_INVALID +messages.search,user,CHAT_ADMIN_REQUIRED INPUT_CONSTRUCTOR_INVALID INPUT_FILTER_INVALID INPUT_USER_DEACTIVATED PEER_ID_INVALID PEER_ID_NOT_SUPPORTED SEARCH_QUERY_EMPTY USER_ID_INVALID messages.searchGifs,user,METHOD_INVALID SEARCH_QUERY_EMPTY messages.searchGlobal,user,SEARCH_QUERY_EMPTY messages.searchStickerSets,user, @@ -274,7 +275,7 @@ messages.sendEncryptedService,user,DATA_INVALID ENCRYPTION_DECLINED MSG_WAIT_FAI messages.sendInlineBotResult,user,CHAT_SEND_INLINE_FORBIDDEN CHAT_WRITE_FORBIDDEN INLINE_RESULT_EXPIRED PEER_ID_INVALID QUERY_ID_EMPTY SCHEDULE_DATE_TOO_LATE SCHEDULE_TOO_MUCH WEBPAGE_CURL_FAILED WEBPAGE_MEDIA_EMPTY messages.sendMedia,both,BOT_PAYMENTS_DISABLED BOT_POLLS_DISABLED BROADCAST_PUBLIC_VOTERS_FORBIDDEN CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED CHAT_SEND_MEDIA_FORBIDDEN CHAT_WRITE_FORBIDDEN EMOTICON_INVALID EXTERNAL_URL_INVALID FILE_PARTS_INVALID FILE_PART_LENGTH_INVALID FILE_REFERENCE_EMPTY FILE_REFERENCE_EXPIRED GAME_BOT_INVALID INPUT_USER_DEACTIVATED MEDIA_CAPTION_TOO_LONG MEDIA_EMPTY PAYMENT_PROVIDER_INVALID PEER_ID_INVALID PHOTO_EXT_INVALID PHOTO_INVALID_DIMENSIONS PHOTO_SAVE_FILE_INVALID POLL_ANSWERS_INVALID POLL_OPTION_DUPLICATE POLL_QUESTION_INVALID QUIZ_CORRECT_ANSWERS_EMPTY QUIZ_CORRECT_ANSWERS_TOO_MUCH QUIZ_CORRECT_ANSWER_INVALID QUIZ_MULTIPLE_INVALID RANDOM_ID_DUPLICATE SCHEDULE_DATE_TOO_LATE SCHEDULE_TOO_MUCH STORAGE_CHECK_FAILED Timeout USER_BANNED_IN_CHANNEL USER_IS_BLOCKED USER_IS_BOT VIDEO_CONTENT_TYPE_INVALID WEBPAGE_CURL_FAILED WEBPAGE_MEDIA_EMPTY messages.sendMessage,both,AUTH_KEY_DUPLICATED BOT_DOMAIN_INVALID BUTTON_DATA_INVALID BUTTON_TYPE_INVALID BUTTON_URL_INVALID CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED CHAT_ID_INVALID CHAT_RESTRICTED CHAT_WRITE_FORBIDDEN ENTITIES_TOO_LONG ENTITY_MENTION_USER_INVALID INPUT_USER_DEACTIVATED MESSAGE_EMPTY MESSAGE_TOO_LONG MSG_ID_INVALID PEER_ID_INVALID POLL_OPTION_INVALID RANDOM_ID_DUPLICATE REPLY_MARKUP_INVALID REPLY_MARKUP_TOO_LONG SCHEDULE_BOT_NOT_ALLOWED SCHEDULE_DATE_TOO_LATE SCHEDULE_STATUS_PRIVATE SCHEDULE_TOO_MUCH Timeout USER_BANNED_IN_CHANNEL USER_IS_BLOCKED USER_IS_BOT YOU_BLOCKED_USER -messages.sendMultiMedia,both,SCHEDULE_DATE_TOO_LATE SCHEDULE_TOO_MUCH +messages.sendMultiMedia,both,MULTI_MEDIA_TOO_LONG SCHEDULE_DATE_TOO_LATE SCHEDULE_TOO_MUCH messages.sendScheduledMessages,user, messages.sendVote,user,MESSAGE_POLL_CLOSED OPTION_INVALID messages.setBotCallbackAnswer,both,QUERY_ID_INVALID URL_INVALID @@ -282,7 +283,7 @@ messages.setBotPrecheckoutResults,both,ERROR_TEXT_EMPTY messages.setBotShippingResults,both,QUERY_ID_INVALID messages.setEncryptedTyping,user,CHAT_ID_INVALID messages.setGameScore,bot,PEER_ID_INVALID USER_BOT_REQUIRED -messages.setInlineBotResults,bot,ARTICLE_TITLE_EMPTY AUDIO_TITLE_EMPTY BUTTON_DATA_INVALID BUTTON_TYPE_INVALID BUTTON_URL_INVALID MESSAGE_EMPTY PHOTO_CONTENT_URL_EMPTY PHOTO_THUMB_URL_EMPTY QUERY_ID_INVALID REPLY_MARKUP_INVALID RESULT_TYPE_INVALID SEND_MESSAGE_MEDIA_INVALID SEND_MESSAGE_TYPE_INVALID START_PARAM_INVALID STICKER_DOCUMENT_INVALID USER_BOT_INVALID WEBDOCUMENT_URL_INVALID +messages.setInlineBotResults,bot,ARTICLE_TITLE_EMPTY AUDIO_TITLE_EMPTY BUTTON_DATA_INVALID BUTTON_TYPE_INVALID BUTTON_URL_INVALID DOCUMENT_INVALID MESSAGE_EMPTY PHOTO_CONTENT_URL_EMPTY PHOTO_THUMB_URL_EMPTY QUERY_ID_INVALID REPLY_MARKUP_INVALID RESULT_TYPE_INVALID SEND_MESSAGE_MEDIA_INVALID SEND_MESSAGE_TYPE_INVALID START_PARAM_INVALID STICKER_DOCUMENT_INVALID USER_BOT_INVALID WEBDOCUMENT_URL_INVALID messages.setInlineGameScore,bot,MESSAGE_ID_INVALID USER_BOT_REQUIRED messages.setTyping,both,CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ID_INVALID CHAT_WRITE_FORBIDDEN PEER_ID_INVALID USER_BANNED_IN_CHANNEL USER_IS_BLOCKED USER_IS_BOT messages.startBot,user,BOT_INVALID PEER_ID_INVALID START_PARAM_EMPTY START_PARAM_INVALID @@ -295,7 +296,7 @@ messages.updatePinnedMessage,both, messages.uploadEncryptedFile,user, messages.uploadMedia,both,BOT_MISSING MEDIA_INVALID PEER_ID_INVALID payments.clearSavedInfo,user, -payments.getBankCardData,user, +payments.getBankCardData,user,BANK_CARD_NUMBER_INVALID payments.getPaymentForm,user,MESSAGE_ID_INVALID payments.getPaymentReceipt,user,MESSAGE_ID_INVALID payments.getSavedInfo,user, @@ -311,8 +312,8 @@ phone.saveCallDebug,user,CALL_PEER_INVALID DATA_JSON_INVALID phone.setCallRating,user,CALL_PEER_INVALID photos.deletePhotos,user, photos.getUserPhotos,both,MAX_ID_INVALID USER_ID_INVALID -photos.updateProfilePhoto,user, -photos.uploadProfilePhoto,user,FILE_PARTS_INVALID IMAGE_PROCESS_FAILED PHOTO_CROP_SIZE_SMALL PHOTO_EXT_INVALID VIDEO_FILE_INVALID +photos.updateProfilePhoto,user,PHOTO_ID_INVALID +photos.uploadProfilePhoto,user,ALBUM_PHOTOS_TOO_MANY FILE_PARTS_INVALID IMAGE_PROCESS_FAILED PHOTO_CROP_SIZE_SMALL PHOTO_EXT_INVALID VIDEO_FILE_INVALID ping,both, reqDHParams,both, reqPq,both, @@ -321,7 +322,7 @@ rpcDropAnswer,both, setClientDHParams,both, stats.getBroadcastStats,user,BROADCAST_REQUIRED CHAT_ADMIN_REQUIRED STATS_MIGRATE_X stats.getMegagroupStats,user,CHAT_ADMIN_REQUIRED MEGAGROUP_REQUIRED STATS_MIGRATE_X -stats.loadAsyncGraph,user, +stats.loadAsyncGraph,user,GRAPH_OUTDATED_RELOAD stickers.addStickerToSet,bot,BOT_MISSING STICKERSET_INVALID stickers.changeStickerPosition,bot,BOT_MISSING STICKER_INVALID 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 USER_ID_INVALID From b02a22eaa3637c0b63e49662b0bbed95245bcb3c Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 7 Nov 2020 11:59:56 +0100 Subject: [PATCH 5/9] Fix .get_buttons failing for some messages sent by the bot Closes #1619. --- telethon/tl/custom/message.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/telethon/tl/custom/message.py b/telethon/tl/custom/message.py index 019ab3f8..d7203a03 100644 --- a/telethon/tl/custom/message.py +++ b/telethon/tl/custom/message.py @@ -1080,7 +1080,8 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC): for row in self.reply_markup.rows: for button in row.buttons: if isinstance(button, types.KeyboardButtonSwitchInline): - if button.same_peer: + # no via_bot_id means the bot sent the message itself (#1619) + if button.same_peer or not self.via_bot_id: bot = self.input_sender if not bot: raise ValueError('No input sender') From 08d5bfcbd0e6c9d30598fc248a5b7a0ac5ee5b2f Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 7 Nov 2020 12:06:10 +0100 Subject: [PATCH 6/9] Fix conv.wait_event not clearing timed out events Closes #1618. --- telethon/tl/custom/conversation.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/telethon/tl/custom/conversation.py b/telethon/tl/custom/conversation.py index 9bccb382..570707e9 100644 --- a/telethon/tl/custom/conversation.py +++ b/telethon/tl/custom/conversation.py @@ -336,7 +336,12 @@ class Conversation(ChatGetter): future = self._client.loop.create_future() self._custom[counter] = (event, future) - return await self._get_result(future, start_time, timeout, self._custom, counter) + try: + return await self._get_result(future, start_time, timeout, self._custom, counter) + except asyncio.TimeoutError: + # Need to remove it from the dict if it times out, else we may + # try and fail to set the result later (#1618). + del self._custom[counter] async def _check_custom(self, built): for key, (ev, fut) in list(self._custom.items()): From a6781c8e34fa8f535a4afdcd5eff5d1348989460 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 7 Nov 2020 12:09:00 +0100 Subject: [PATCH 7/9] Don't cache SLOW_MODE_WAIT in _flood_waited_requests Closes #1600. --- telethon/client/users.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/telethon/client/users.py b/telethon/client/users.py index b2243a2e..ddd41433 100644 --- a/telethon/client/users.py +++ b/telethon/client/users.py @@ -94,8 +94,10 @@ class UserMethods: if utils.is_list_like(request): request = request[request_index] - self._flood_waited_requests\ - [request.CONSTRUCTOR_ID] = time.time() + e.seconds + # SLOW_MODE_WAIT is chat-specific, not request-specific + if not isinstance(e, errors.SlowModeWaitError): + self._flood_waited_requests\ + [request.CONSTRUCTOR_ID] = time.time() + e.seconds # In test servers, FLOOD_WAIT_0 has been observed, and sleeping for # such a short amount will cause retries very fast leading to issues. From 0d8497bf3b7b8fa207a349d791c40ae47a8f9a81 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 7 Nov 2020 12:18:55 +0100 Subject: [PATCH 8/9] Correct and simplify the way channel IDs are marked Closes #1359. --- telethon/utils.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/telethon/utils.py b/telethon/utils.py index e9c1468d..81ba9523 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -1009,14 +1009,8 @@ def get_peer_id(peer, add_mark=True): if not add_mark: return peer.channel_id - # Concat -100 through math tricks, .to_supergroup() on - # Madeline IDs will be strictly positive -> log works. - try: - return -(peer.channel_id + pow( - 10, math.floor(math.log10(peer.channel_id) + 3))) - except ValueError: - raise TypeError('Cannot get marked ID of a channel ' - 'unless its ID is strictly positive') from None + # Growing backwards from -100_0000_000_000 indicates it's a channel + return -(1000000000000 + peer.channel_id) def resolve_id(marked_id): From e1d2c81dca7c26c11365457ad2f7857853249471 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 7 Nov 2020 12:46:46 +0100 Subject: [PATCH 9/9] Parse part of newer bot file IDs for photos Helps with #1613. --- telethon/utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/telethon/utils.py b/telethon/utils.py index 81ba9523..a5f95e9a 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -1161,15 +1161,20 @@ def resolve_bot_file_id(file_id): attributes=attributes, file_reference=b'' ) - elif (version == 2 and len(data) == 44) or (version == 4 and len(data) == 49): + elif (version == 2 and len(data) == 44) or (version == 4 and len(data) in (49, 77)): if version == 2: (file_type, dc_id, media_id, access_hash, volume_id, secret, local_id) = struct.unpack('