2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-27 20:37:54 +00:00

Fix set_chat_photo not working because of new file ids

This commit is contained in:
Dan 2019-08-21 09:56:33 +02:00
parent 77e4128d54
commit 0011d12be5

View File

@ -17,7 +17,6 @@
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import os import os
from struct import unpack
from typing import Union from typing import Union
from pyrogram.api import functions, types from pyrogram.api import functions, types
@ -62,15 +61,8 @@ class SetChatPhoto(BaseClient):
if os.path.exists(photo): if os.path.exists(photo):
photo = types.InputChatUploadedPhoto(file=self.save_file(photo)) photo = types.InputChatUploadedPhoto(file=self.save_file(photo))
else: else:
unpacked = unpack("<iiqqc", utils.decode(photo)) photo = utils.get_input_media_from_file_id(photo)
photo = types.InputChatPhoto(id=photo.id)
photo = types.InputChatPhoto(
id=types.InputPhoto(
id=unpacked[2],
access_hash=unpacked[3],
file_reference=b""
)
)
if isinstance(peer, types.InputPeerChat): if isinstance(peer, types.InputPeerChat):
self.send( self.send(