Update documentation with takeout, add new known errors

This commit is contained in:
Lonami Exo 2019-01-05 17:31:26 +01:00
parent 0a147d5b95
commit a5b107e6c9
4 changed files with 37 additions and 3 deletions

View File

@ -5,7 +5,8 @@ Telethon
⭐️ Thanks **everyone** who has starred the project, it means a lot! ⭐️ Thanks **everyone** who has starred the project, it means a lot!
|logo| **Telethon** is an asyncio_ **Python 3** |logo| **Telethon** is an asyncio_ **Python 3**
MTProto_ library to interact with Telegram_'s API. MTProto_ library to interact with Telegram_'s API
as a user or through a bot account (bot API alternative).
.. important:: .. important::

View File

@ -262,6 +262,36 @@ Or just some IDs:
message_1337 = client.get_messages(chats, ids=1337) message_1337 = client.get_messages(chats, ids=1337)
Exporting Messages
******************
If you plan on exporting data from your Telegram account, such as the entire
message history from your private conversations, chats or channels, or if you
plan to download a lot of media, you may prefer to do this within a *takeout*
session. Takeout sessions let you export data from your account with lower
flood wait limits.
To start a takeout session, simply call `client.takeout()
<telethon.client.account.AccountMethods.takeout>`:
.. code-block:: python
from telethon import errors
try:
with client.takeout() as takeout:
for message in takeout.iter_messages(chat, wait_time=0):
... # Do something with the message
except errors.TakeoutInitDelayError as e:
print('Must wait', e.seconds, 'before takeout')
Depending on the condition of the session (for example, when it's very
young and the method has not been called before), you may or not need
to ``except errors.TakeoutInitDelayError``. However, it is good practice.
Sending Messages Sending Messages
**************** ****************

View File

@ -20,6 +20,7 @@ BOT_INLINE_DISABLED,400,This bot can't be used in inline mode
BOT_INVALID,400,This is not a valid bot BOT_INVALID,400,This is not a valid bot
BOT_METHOD_INVALID,400,The API access for bot users is restricted. The method you tried to invoke cannot be executed as a bot BOT_METHOD_INVALID,400,The API access for bot users is restricted. The method you tried to invoke cannot be executed as a bot
BOT_MISSING,400,This method can only be run by a bot BOT_MISSING,400,This method can only be run by a bot
BOT_POLLS_DISABLED,400,You cannot create polls under a bot account
BUTTON_DATA_INVALID,400,The provided button data is invalid BUTTON_DATA_INVALID,400,The provided button data is invalid
BUTTON_TYPE_INVALID,400,The type of one of the buttons you provided is invalid BUTTON_TYPE_INVALID,400,The type of one of the buttons you provided is invalid
BUTTON_URL_INVALID,400,Button URL invalid BUTTON_URL_INVALID,400,Button URL invalid
@ -187,6 +188,7 @@ 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_MCGET_FAIL,,"Telegram is having internal issues, please try again later."
RSA_DECRYPT_FAILED,400,Internal RSA decryption failed RSA_DECRYPT_FAILED,400,Internal RSA decryption failed
SEARCH_QUERY_EMPTY,400,The search query is empty SEARCH_QUERY_EMPTY,400,The search query is empty
SEND_MESSAGE_MEDIA_INVALID,400,The message media was invalid or not specified
SEND_MESSAGE_TYPE_INVALID,400,The message type is invalid SEND_MESSAGE_TYPE_INVALID,400,The message type is invalid
SESSION_EXPIRED,401,The authorization has expired SESSION_EXPIRED,401,The authorization has expired
SESSION_PASSWORD_NEEDED,401,Two-steps verification is enabled and a password is required SESSION_PASSWORD_NEEDED,401,Two-steps verification is enabled and a password is required
@ -205,6 +207,7 @@ STICKER_PNG_DIMENSIONS,400,Sticker png dimensions invalid
STORAGE_CHECK_FAILED,500,Server storage check failed STORAGE_CHECK_FAILED,500,Server storage check failed
STORE_INVALID_SCALAR_TYPE,500, STORE_INVALID_SCALAR_TYPE,500,
TAKEOUT_INIT_DELAY_X,420,A wait of {seconds} seconds is required before being able to initiate the takeout TAKEOUT_INIT_DELAY_X,420,A wait of {seconds} seconds is required before being able to initiate the takeout
TAKEOUT_INVALID,400,The takeout session has been invalidated by another data export session
TAKEOUT_REQUIRED,400,You must initialize a takeout request first TAKEOUT_REQUIRED,400,You must initialize a takeout request first
TEMP_AUTH_KEY_EMPTY,400,No temporary auth key provided TEMP_AUTH_KEY_EMPTY,400,No temporary auth key provided
Timeout,-503,A timeout occurred while fetching data from the bot Timeout,-503,A timeout occurred while fetching data from the bot

1 name codes description
20 BOT_INVALID 400 This is not a valid bot
21 BOT_METHOD_INVALID 400 The API access for bot users is restricted. The method you tried to invoke cannot be executed as a bot
22 BOT_MISSING 400 This method can only be run by a bot
23 BOT_POLLS_DISABLED 400 You cannot create polls under a bot account
24 BUTTON_DATA_INVALID 400 The provided button data is invalid
25 BUTTON_TYPE_INVALID 400 The type of one of the buttons you provided is invalid
26 BUTTON_URL_INVALID 400 Button URL invalid
188 RPC_MCGET_FAIL Telegram is having internal issues, please try again later.
189 RSA_DECRYPT_FAILED 400 Internal RSA decryption failed
190 SEARCH_QUERY_EMPTY 400 The search query is empty
191 SEND_MESSAGE_MEDIA_INVALID 400 The message media was invalid or not specified
192 SEND_MESSAGE_TYPE_INVALID 400 The message type is invalid
193 SESSION_EXPIRED 401 The authorization has expired
194 SESSION_PASSWORD_NEEDED 401 Two-steps verification is enabled and a password is required
207 STORAGE_CHECK_FAILED 500 Server storage check failed
208 STORE_INVALID_SCALAR_TYPE 500
209 TAKEOUT_INIT_DELAY_X 420 A wait of {seconds} seconds is required before being able to initiate the takeout
210 TAKEOUT_INVALID 400 The takeout session has been invalidated by another data export session
211 TAKEOUT_REQUIRED 400 You must initialize a takeout request first
212 TEMP_AUTH_KEY_EMPTY 400 No temporary auth key provided
213 Timeout -503 A timeout occurred while fetching data from the bot

View File

@ -139,7 +139,7 @@ messages.sendEncrypted,unknown,CHAT_ID_INVALID DATA_INVALID ENCRYPTION_DECLINED
messages.sendEncryptedFile,unknown,MSG_WAIT_FAILED messages.sendEncryptedFile,unknown,MSG_WAIT_FAILED
messages.sendEncryptedService,unknown,DATA_INVALID ENCRYPTION_DECLINED MSG_WAIT_FAILED USER_IS_BLOCKED messages.sendEncryptedService,unknown,DATA_INVALID ENCRYPTION_DECLINED MSG_WAIT_FAILED USER_IS_BLOCKED
messages.sendInlineBotResult,user,CHAT_WRITE_FORBIDDEN INLINE_RESULT_EXPIRED PEER_ID_INVALID QUERY_ID_EMPTY WEBPAGE_CURL_FAILED WEBPAGE_MEDIA_EMPTY messages.sendInlineBotResult,user,CHAT_WRITE_FORBIDDEN INLINE_RESULT_EXPIRED PEER_ID_INVALID QUERY_ID_EMPTY WEBPAGE_CURL_FAILED WEBPAGE_MEDIA_EMPTY
messages.sendMedia,unknown,CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED CHAT_SEND_MEDIA_FORBIDDEN CHAT_WRITE_FORBIDDEN EXTERNAL_URL_INVALID FILE_PARTS_INVALID FILE_PART_LENGTH_INVALID INPUT_USER_DEACTIVATED MEDIA_CAPTION_TOO_LONG MEDIA_EMPTY PEER_ID_INVALID PHOTO_EXT_INVALID PHOTO_INVALID_DIMENSIONS PHOTO_SAVE_FILE_INVALID RANDOM_ID_DUPLICATE STORAGE_CHECK_FAILED Timeout USER_BANNED_IN_CHANNEL USER_IS_BLOCKED USER_IS_BOT WEBPAGE_CURL_FAILED WEBPAGE_MEDIA_EMPTY messages.sendMedia,unknown,BOT_POLLS_DISABLED CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED CHAT_SEND_MEDIA_FORBIDDEN CHAT_WRITE_FORBIDDEN EXTERNAL_URL_INVALID FILE_PARTS_INVALID FILE_PART_LENGTH_INVALID INPUT_USER_DEACTIVATED MEDIA_CAPTION_TOO_LONG MEDIA_EMPTY PEER_ID_INVALID PHOTO_EXT_INVALID PHOTO_INVALID_DIMENSIONS PHOTO_SAVE_FILE_INVALID RANDOM_ID_DUPLICATE STORAGE_CHECK_FAILED Timeout USER_BANNED_IN_CHANNEL USER_IS_BLOCKED USER_IS_BOT WEBPAGE_CURL_FAILED WEBPAGE_MEDIA_EMPTY
messages.sendMessage,unknown,AUTH_KEY_DUPLICATED BUTTON_DATA_INVALID BUTTON_TYPE_INVALID BUTTON_URL_INVALID CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED CHAT_ID_INVALID CHAT_RESTRICTED CHAT_WRITE_FORBIDDEN ENTITY_MENTION_USER_INVALID INPUT_USER_DEACTIVATED MESSAGE_EMPTY MESSAGE_TOO_LONG PEER_ID_INVALID RANDOM_ID_DUPLICATE REPLY_MARKUP_INVALID REPLY_MARKUP_TOO_LONG Timeout USER_BANNED_IN_CHANNEL USER_IS_BLOCKED USER_IS_BOT YOU_BLOCKED_USER messages.sendMessage,unknown,AUTH_KEY_DUPLICATED BUTTON_DATA_INVALID BUTTON_TYPE_INVALID BUTTON_URL_INVALID CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED CHAT_ID_INVALID CHAT_RESTRICTED CHAT_WRITE_FORBIDDEN ENTITY_MENTION_USER_INVALID INPUT_USER_DEACTIVATED MESSAGE_EMPTY MESSAGE_TOO_LONG PEER_ID_INVALID RANDOM_ID_DUPLICATE REPLY_MARKUP_INVALID REPLY_MARKUP_TOO_LONG Timeout USER_BANNED_IN_CHANNEL USER_IS_BLOCKED USER_IS_BOT YOU_BLOCKED_USER
messages.sendScreenshotNotification,user,PEER_ID_INVALID messages.sendScreenshotNotification,user,PEER_ID_INVALID
messages.setBotCallbackAnswer,unknown,QUERY_ID_INVALID URL_INVALID messages.setBotCallbackAnswer,unknown,QUERY_ID_INVALID URL_INVALID
@ -147,7 +147,7 @@ messages.setBotPrecheckoutResults,unknown,ERROR_TEXT_EMPTY
messages.setBotShippingResults,unknown,QUERY_ID_INVALID messages.setBotShippingResults,unknown,QUERY_ID_INVALID
messages.setEncryptedTyping,user,CHAT_ID_INVALID messages.setEncryptedTyping,user,CHAT_ID_INVALID
messages.setGameScore,unknown,PEER_ID_INVALID USER_BOT_REQUIRED messages.setGameScore,unknown,PEER_ID_INVALID USER_BOT_REQUIRED
messages.setInlineBotResults,unknown,ARTICLE_TITLE_EMPTY BUTTON_DATA_INVALID BUTTON_TYPE_INVALID BUTTON_URL_INVALID MESSAGE_EMPTY QUERY_ID_INVALID REPLY_MARKUP_INVALID RESULT_TYPE_INVALID SEND_MESSAGE_TYPE_INVALID START_PARAM_INVALID USER_BOT_INVALID messages.setInlineBotResults,unknown,ARTICLE_TITLE_EMPTY BUTTON_DATA_INVALID BUTTON_TYPE_INVALID BUTTON_URL_INVALID MESSAGE_EMPTY QUERY_ID_INVALID REPLY_MARKUP_INVALID RESULT_TYPE_INVALID SEND_MESSAGE_MEDIA_INVALID SEND_MESSAGE_TYPE_INVALID START_PARAM_INVALID USER_BOT_INVALID
messages.setInlineGameScore,unknown,MESSAGE_ID_INVALID USER_BOT_REQUIRED messages.setInlineGameScore,unknown,MESSAGE_ID_INVALID USER_BOT_REQUIRED
messages.setTyping,unknown,CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ID_INVALID CHAT_WRITE_FORBIDDEN PEER_ID_INVALID USER_BANNED_IN_CHANNEL USER_IS_BLOCKED USER_IS_BOT messages.setTyping,unknown,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 messages.startBot,user,BOT_INVALID PEER_ID_INVALID START_PARAM_EMPTY START_PARAM_INVALID

1 method usability errors
139 messages.sendEncryptedFile unknown MSG_WAIT_FAILED
140 messages.sendEncryptedService unknown DATA_INVALID ENCRYPTION_DECLINED MSG_WAIT_FAILED USER_IS_BLOCKED
141 messages.sendInlineBotResult user CHAT_WRITE_FORBIDDEN INLINE_RESULT_EXPIRED PEER_ID_INVALID QUERY_ID_EMPTY WEBPAGE_CURL_FAILED WEBPAGE_MEDIA_EMPTY
142 messages.sendMedia unknown CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED CHAT_SEND_MEDIA_FORBIDDEN CHAT_WRITE_FORBIDDEN EXTERNAL_URL_INVALID FILE_PARTS_INVALID FILE_PART_LENGTH_INVALID INPUT_USER_DEACTIVATED MEDIA_CAPTION_TOO_LONG MEDIA_EMPTY PEER_ID_INVALID PHOTO_EXT_INVALID PHOTO_INVALID_DIMENSIONS PHOTO_SAVE_FILE_INVALID RANDOM_ID_DUPLICATE STORAGE_CHECK_FAILED Timeout USER_BANNED_IN_CHANNEL USER_IS_BLOCKED USER_IS_BOT WEBPAGE_CURL_FAILED WEBPAGE_MEDIA_EMPTY BOT_POLLS_DISABLED CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED CHAT_SEND_MEDIA_FORBIDDEN CHAT_WRITE_FORBIDDEN EXTERNAL_URL_INVALID FILE_PARTS_INVALID FILE_PART_LENGTH_INVALID INPUT_USER_DEACTIVATED MEDIA_CAPTION_TOO_LONG MEDIA_EMPTY PEER_ID_INVALID PHOTO_EXT_INVALID PHOTO_INVALID_DIMENSIONS PHOTO_SAVE_FILE_INVALID RANDOM_ID_DUPLICATE STORAGE_CHECK_FAILED Timeout USER_BANNED_IN_CHANNEL USER_IS_BLOCKED USER_IS_BOT WEBPAGE_CURL_FAILED WEBPAGE_MEDIA_EMPTY
143 messages.sendMessage unknown AUTH_KEY_DUPLICATED BUTTON_DATA_INVALID BUTTON_TYPE_INVALID BUTTON_URL_INVALID CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED CHAT_ID_INVALID CHAT_RESTRICTED CHAT_WRITE_FORBIDDEN ENTITY_MENTION_USER_INVALID INPUT_USER_DEACTIVATED MESSAGE_EMPTY MESSAGE_TOO_LONG PEER_ID_INVALID RANDOM_ID_DUPLICATE REPLY_MARKUP_INVALID REPLY_MARKUP_TOO_LONG Timeout USER_BANNED_IN_CHANNEL USER_IS_BLOCKED USER_IS_BOT YOU_BLOCKED_USER
144 messages.sendScreenshotNotification user PEER_ID_INVALID
145 messages.setBotCallbackAnswer unknown QUERY_ID_INVALID URL_INVALID
147 messages.setBotShippingResults unknown QUERY_ID_INVALID
148 messages.setEncryptedTyping user CHAT_ID_INVALID
149 messages.setGameScore unknown PEER_ID_INVALID USER_BOT_REQUIRED
150 messages.setInlineBotResults unknown ARTICLE_TITLE_EMPTY BUTTON_DATA_INVALID BUTTON_TYPE_INVALID BUTTON_URL_INVALID MESSAGE_EMPTY QUERY_ID_INVALID REPLY_MARKUP_INVALID RESULT_TYPE_INVALID SEND_MESSAGE_TYPE_INVALID START_PARAM_INVALID USER_BOT_INVALID ARTICLE_TITLE_EMPTY BUTTON_DATA_INVALID BUTTON_TYPE_INVALID BUTTON_URL_INVALID MESSAGE_EMPTY QUERY_ID_INVALID REPLY_MARKUP_INVALID RESULT_TYPE_INVALID SEND_MESSAGE_MEDIA_INVALID SEND_MESSAGE_TYPE_INVALID START_PARAM_INVALID USER_BOT_INVALID
151 messages.setInlineGameScore unknown MESSAGE_ID_INVALID USER_BOT_REQUIRED
152 messages.setTyping unknown CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ID_INVALID CHAT_WRITE_FORBIDDEN PEER_ID_INVALID USER_BANNED_IN_CHANNEL USER_IS_BLOCKED USER_IS_BOT
153 messages.startBot user BOT_INVALID PEER_ID_INVALID START_PARAM_EMPTY START_PARAM_INVALID