Skip to content

Commit

Permalink
Ignore improperly formatted errors from Telegram's JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonami committed Jan 11, 2023
1 parent 94cc897 commit c932d79
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 0 additions & 4 deletions telethon_generator/data/errors.csv
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ FILE_PART_SIZE_CHANGED,400,The file part size (chunk size) cannot change during
FILE_PART_SIZE_INVALID,400,The provided file part size is invalid
FILE_PART_TOO_BIG,400,The uploaded file part is too big
FILE_PART_X_MISSING,400,Part {which} of the file is missing from storage
FILE_REFERENCE_*,400,"The file reference expired, it [must be refreshed](https://core.telegram.org/api/file_reference)"
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
FILE_REFERENCE_INVALID,400,The file reference is invalid or you can't do that operation on such message
Expand Down Expand Up @@ -229,9 +228,6 @@ INVITE_HASH_INVALID,400,The invite hash is invalid
INVITE_REQUEST_SENT,400,You have successfully requested to join this chat or channel
INVITE_REVOKED_MISSING,400,The specified invite link was already revoked or is invalid
INVOICE_PAYLOAD_INVALID,400,The specified invoice payload is invalid
Invalid msg_resend_req query,-500,Invalid msg_resend_req query
Invalid msgs_ack query,-500,Invalid msgs_ack query
Invalid msgs_state_req query,-500,Invalid msgs_state_req query
JOIN_AS_PEER_INVALID,400,The specified peer cannot be used to join a group call
LANG_CODE_INVALID,400,The specified language code is invalid
LANG_CODE_NOT_SUPPORTED,400,The specified language code is not supported
Expand Down
2 changes: 2 additions & 0 deletions telethon_generator/syncerrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def get_desc(code):
for int_code, errors in tg_data['errors'].items():
int_code = int(int_code) # json does not support non-string keys
for code, methods in errors.items():
if not re.match(r'\w+', code):
continue # skip, full code is unknown (contains asterisk or is multiple words)
str_code = code.replace('%d', 'X')
if error := self_errors.get(str_code):
error.int_codes.append(int_code) # de-duplicated once later
Expand Down

0 comments on commit c932d79

Please sign in to comment.