mirror of
				https://github.com/LonamiWebs/Telethon.git
				synced 2025-11-04 09:57:29 +03:00 
			
		
		
		
	Enhance and use .get_input_photo on the generated code
This commit is contained in:
		
							parent
							
								
									62aec947c0
								
							
						
					
					
						commit
						83677fc927
					
				| 
						 | 
					@ -20,8 +20,8 @@ from .tl.types import (
 | 
				
			||||||
    GeoPointEmpty, InputGeoPointEmpty, Photo, InputPhoto, PhotoEmpty,
 | 
					    GeoPointEmpty, InputGeoPointEmpty, Photo, InputPhoto, PhotoEmpty,
 | 
				
			||||||
    InputPhotoEmpty, FileLocation, ChatPhotoEmpty, UserProfilePhotoEmpty,
 | 
					    InputPhotoEmpty, FileLocation, ChatPhotoEmpty, UserProfilePhotoEmpty,
 | 
				
			||||||
    FileLocationUnavailable, InputMediaUploadedDocument,
 | 
					    FileLocationUnavailable, InputMediaUploadedDocument,
 | 
				
			||||||
    InputMediaUploadedPhoto,
 | 
					    InputMediaUploadedPhoto, DocumentAttributeFilename, photos
 | 
				
			||||||
    DocumentAttributeFilename)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_display_name(entity):
 | 
					def get_display_name(entity):
 | 
				
			||||||
| 
						 | 
					@ -188,6 +188,9 @@ def get_input_photo(photo):
 | 
				
			||||||
    if type(photo).SUBCLASS_OF_ID == 0x846363e0:  # crc32(b'InputPhoto')
 | 
					    if type(photo).SUBCLASS_OF_ID == 0x846363e0:  # crc32(b'InputPhoto')
 | 
				
			||||||
        return photo
 | 
					        return photo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if isinstance(photo, photos.Photo):
 | 
				
			||||||
 | 
					        photo = photo.photo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if isinstance(photo, Photo):
 | 
					    if isinstance(photo, Photo):
 | 
				
			||||||
        return InputPhoto(id=photo.id, access_hash=photo.access_hash)
 | 
					        return InputPhoto(id=photo.id, access_hash=photo.access_hash)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -143,7 +143,7 @@ class TLGenerator:
 | 
				
			||||||
                    builder.writeln(
 | 
					                    builder.writeln(
 | 
				
			||||||
                        'from {}.utils import get_input_peer, '
 | 
					                        'from {}.utils import get_input_peer, '
 | 
				
			||||||
                        'get_input_channel, get_input_user, '
 | 
					                        'get_input_channel, get_input_user, '
 | 
				
			||||||
                        'get_input_media'.format('.' * depth)
 | 
					                        'get_input_media, get_input_photo'.format('.' * depth)
 | 
				
			||||||
                    )
 | 
					                    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                # Import 'os' for those needing access to 'os.urandom()'
 | 
					                # Import 'os' for those needing access to 'os.urandom()'
 | 
				
			||||||
| 
						 | 
					@ -402,6 +402,8 @@ class TLGenerator:
 | 
				
			||||||
            TLGenerator.write_get_input(builder, arg, 'get_input_user')
 | 
					            TLGenerator.write_get_input(builder, arg, 'get_input_user')
 | 
				
			||||||
        elif arg.type == 'InputMedia' and tlobject.is_function:
 | 
					        elif arg.type == 'InputMedia' and tlobject.is_function:
 | 
				
			||||||
            TLGenerator.write_get_input(builder, arg, 'get_input_media')
 | 
					            TLGenerator.write_get_input(builder, arg, 'get_input_media')
 | 
				
			||||||
 | 
					        elif arg.type == 'InputPhoto' and tlobject.is_function:
 | 
				
			||||||
 | 
					            TLGenerator.write_get_input(builder, arg, 'get_input_photo')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            builder.writeln('self.{0} = {0}'.format(arg.name))
 | 
					            builder.writeln('self.{0} = {0}'.format(arg.name))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user