mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 01:16:35 +03:00
Fix MemoryError on get_input_media(game)
Because an integer was being passed where a TLObject was expected, so the serialization with bytes() was actually requesting that many bytes as opposed to properly converting the expected object.
This commit is contained in:
parent
364afd61e1
commit
582a61192a
|
@ -483,7 +483,10 @@ def get_input_media(
|
|||
file=media, mime_type=mime, attributes=attrs)
|
||||
|
||||
if isinstance(media, types.MessageMediaGame):
|
||||
return types.InputMediaGame(id=media.game.id)
|
||||
return types.InputMediaGame(id=types.InputGameID(
|
||||
id=media.game.id,
|
||||
access_hash=media.game.access_hash
|
||||
))
|
||||
|
||||
if isinstance(media, types.MessageMediaContact):
|
||||
return types.InputMediaContact(
|
||||
|
|
|
@ -106,6 +106,7 @@ FLOOD_WAIT_X,420,A wait of {seconds} seconds is required
|
|||
FOLDER_ID_EMPTY,400,The folder you tried to delete was already empty
|
||||
FOLDER_ID_INVALID,400,The folder you tried to use was not valid
|
||||
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
|
||||
GROUPED_MEDIA_INVALID,400,Invalid grouped media
|
||||
HASH_INVALID,400,The provided hash is invalid
|
||||
|
@ -133,7 +134,7 @@ 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
|
||||
MEDIA_CAPTION_TOO_LONG,400,The caption is too long
|
||||
MEDIA_EMPTY,400,The provided media object is invalid
|
||||
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
|
||||
MEDIA_NEW_INVALID,400,The new media to edit the message with is invalid (such as stickers or voice notes)
|
||||
MEDIA_PREV_INVALID,400,The old media cannot be edited with anything else (such as stickers or voice notes)
|
||||
|
|
|
|
@ -237,7 +237,7 @@ messages.sendEncrypted,user,CHAT_ID_INVALID DATA_INVALID ENCRYPTION_DECLINED MSG
|
|||
messages.sendEncryptedFile,user,MSG_WAIT_FAILED
|
||||
messages.sendEncryptedService,user,DATA_INVALID ENCRYPTION_DECLINED MSG_WAIT_FAILED USER_IS_BLOCKED
|
||||
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 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 PAYMENT_PROVIDER_INVALID PEER_ID_INVALID PHOTO_EXT_INVALID PHOTO_INVALID_DIMENSIONS PHOTO_SAVE_FILE_INVALID POLL_OPTION_DUPLICATE 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.sendMedia,both,BOT_PAYMENTS_DISABLED 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 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_OPTION_DUPLICATE 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 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_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.sendReaction,User,REACTION_INVALID
|
||||
|
|
|
18
tests/telethon/test_utils.py
Normal file
18
tests/telethon/test_utils.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
from telethon import utils
|
||||
from telethon.tl.types import (
|
||||
MessageMediaGame, Game, PhotoEmpty
|
||||
)
|
||||
|
||||
|
||||
def test_game_input_media_memory_error():
|
||||
large_long = 2**62
|
||||
media = MessageMediaGame(Game(
|
||||
id=large_long, # <- key to trigger `MemoryError`
|
||||
access_hash=large_long,
|
||||
short_name='short_name',
|
||||
title='title',
|
||||
description='description',
|
||||
photo=PhotoEmpty(large_long),
|
||||
))
|
||||
input_media = utils.get_input_media(media)
|
||||
bytes(input_media) # <- shouldn't raise `MemoryError`
|
Loading…
Reference in New Issue
Block a user