mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-24 15:30:48 +03:00
Finish update to layer 98
This commit is contained in:
parent
013525797a
commit
bb23bc0fd2
|
@ -180,7 +180,7 @@ class DownloadMethods(UserMethods):
|
|||
Downloads the given input location to a file.
|
||||
|
||||
Args:
|
||||
input_location (:tl:`FileLocation` | :tl:`InputFileLocation`):
|
||||
input_location (:tl:`InputFileLocation`):
|
||||
The file location from which the file will be downloaded.
|
||||
See `telethon.utils.get_input_location` source for a complete
|
||||
list of supported types.
|
||||
|
|
|
@ -420,13 +420,6 @@ def get_input_media(
|
|||
if isinstance(media, types.MessageMediaGame):
|
||||
return types.InputMediaGame(id=media.game.id)
|
||||
|
||||
if isinstance(media, (types.ChatPhoto, types.UserProfilePhoto)):
|
||||
if isinstance(media.photo_big, types.FileLocationUnavailable):
|
||||
media = media.photo_small
|
||||
else:
|
||||
media = media.photo_big
|
||||
return get_input_media(media, is_photo=True)
|
||||
|
||||
if isinstance(media, types.MessageMediaContact):
|
||||
return types.InputMediaContact(
|
||||
phone_number=media.phone_number,
|
||||
|
@ -451,7 +444,8 @@ def get_input_media(
|
|||
if isinstance(media, (
|
||||
types.MessageMediaEmpty, types.MessageMediaUnsupported,
|
||||
types.ChatPhotoEmpty, types.UserProfilePhotoEmpty,
|
||||
types.FileLocationUnavailable)):
|
||||
types.ChatPhoto, types.UserProfilePhoto,
|
||||
types.FileLocationToBeDeprecated)):
|
||||
return types.InputMediaEmpty()
|
||||
|
||||
if isinstance(media, types.Message):
|
||||
|
@ -644,13 +638,6 @@ def get_input_location(location):
|
|||
))
|
||||
|
||||
if isinstance(location, types.FileLocationToBeDeprecated):
|
||||
return (None, types.InputFileLocation(
|
||||
volume_id=location.volume_id,
|
||||
local_id=location.local_id,
|
||||
secret=0,
|
||||
file_reference=b''
|
||||
))
|
||||
elif isinstance(location, types.FileLocationUnavailable):
|
||||
raise TypeError('Unavailable location cannot be used as input')
|
||||
|
||||
_raise_cast_fail(location, 'InputFileLocation')
|
||||
|
@ -991,15 +978,24 @@ def resolve_bot_file_id(file_id):
|
|||
|
||||
# Thumbnails (small) always have ID 0; otherwise size 'x'
|
||||
photo_size = 's' if media_id or access_hash else 'x'
|
||||
return types.Photo(id=media_id, access_hash=access_hash, sizes=[
|
||||
types.PhotoSize(photo_size, location=types.FileLocation(
|
||||
dc_id=dc_id,
|
||||
volume_id=volume_id,
|
||||
secret=secret,
|
||||
local_id=local_id,
|
||||
file_reference=b''
|
||||
), w=0, h=0, size=0)
|
||||
], file_reference=b'', date=None)
|
||||
return types.Photo(
|
||||
id=media_id,
|
||||
access_hash=access_hash,
|
||||
file_reference=b'',
|
||||
date=None,
|
||||
sizes=[types.PhotoSize(
|
||||
type=photo_size,
|
||||
location=types.FileLocationToBeDeprecated(
|
||||
volume_id=volume_id,
|
||||
local_id=local_id
|
||||
),
|
||||
w=0,
|
||||
h=0,
|
||||
size=0
|
||||
)],
|
||||
dc_id=dc_id,
|
||||
has_stickers=None
|
||||
)
|
||||
|
||||
|
||||
def pack_bot_file_id(file):
|
||||
|
@ -1038,13 +1034,13 @@ def pack_bot_file_id(file):
|
|||
size = next((x for x in reversed(file.sizes) if isinstance(
|
||||
x, (types.PhotoSize, types.PhotoCachedSize))), None)
|
||||
|
||||
if not size or not isinstance(size.location, types.FileLocation):
|
||||
if not size:
|
||||
return None
|
||||
|
||||
size = size.location
|
||||
return _encode_telegram_base64(_rle_encode(struct.pack(
|
||||
'<iiqqqqib', 2, size.dc_id, file.id, file.access_hash,
|
||||
size.volume_id, size.secret, size.local_id, 2
|
||||
'<iiqqqqib', 2, file.dc_id, file.id, file.access_hash,
|
||||
size.volume_id, 0, size.local_id, 2 # 0 = old `secret`
|
||||
)))
|
||||
else:
|
||||
return None
|
||||
|
|
|
@ -251,6 +251,7 @@ USER_BOT_REQUIRED,400,This method can only be called by a bot
|
|||
USER_CHANNELS_TOO_MUCH,403,One of the users you tried to add is already in too many channels/supergroups
|
||||
USER_CREATOR,400,"You can't leave this channel, because you're its creator"
|
||||
USER_DEACTIVATED,401,The user has been deleted/deactivated
|
||||
USER_DEACTIVATED_BAN,401,The user has been deleted/deactivated
|
||||
USER_ID_INVALID,400,"Invalid object ID for a user. Make sure to pass the right types, for instance making sure that the request is designed for users or otherwise look for a different one more suited"
|
||||
USER_INVALID,400,The given user was invalid
|
||||
USER_IS_BLOCKED,400 403,User is blocked
|
||||
|
|
|
Loading…
Reference in New Issue
Block a user