File tree Expand file tree Collapse file tree 3 files changed +13
-11
lines changed
Expand file tree Collapse file tree 3 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,15 @@ class ChatPhoto(BaseObject, mixins.FileMixin):
5555 }
5656 _check_equality_ = "small_file_id"
5757
58+ def save (self , * args , small = False , ** kwargs ):
59+ """Workaround for dealing with big and small chat photos"""
60+ if small :
61+ self .file_id = self .small
62+ else :
63+ self .file_id = self .big
64+ super (ChatPhoto , self ).save (* args , ** kwargs )
65+ del self .file_id
66+
5867
5968class Photo (mixins .FileMixin ):
6069 """Custom representation of a photo
Original file line number Diff line number Diff line change @@ -581,16 +581,9 @@ class FileMixin:
581581 """Add some methods for files"""
582582
583583 @_require_api
584- def save (self , path , big = True ):
584+ def save (self , path ):
585585 """Save the file to a particular path"""
586- if isinstance (self , ChatPhoto ):
587- if big :
588- _file_id = self .big
589- else :
590- _file_id = self .small
591- else :
592- _file_id = self .file_id
593- response = self ._api .call ("getFile" , {"file_id" : _file_id })
586+ response = self ._api .call ("getFile" , {"file_id" : self .file_id })
594587
595588 # Save the file to the wanted path
596589 downloaded = self ._api .file_content (response ["result" ]["file_path" ])
Original file line number Diff line number Diff line change @@ -2456,14 +2456,14 @@ about its business.
24562456
24572457 The string ID of the 160x160 version of the chat photo
24582458
2459- .. py :method :: save(path [, big= True ])
2459+ .. py :method :: save(path [, small= False ])
24602460
24612461 Save the image represented to a file located by *path *. Be aware that
24622462 Telegram does not provide the name of the original file sent by its
24632463 sender. This should be generated as part of the path.
24642464
24652465 :param str path: The file name path locating where the image should be saved.
2466- :param bool big : Whether it should save the big or the small version of the chat photo
2466+ :param bool small : Whether it should save the big or the small version of the chat photo
24672467
24682468 .. versionadded :: 0.7
24692469
You can’t perform that action at this time.
0 commit comments