Skip to content

Commit 1099a97

Browse files
fix
1 parent 7104200 commit 1099a97

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

vk_api/vk_upload.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,23 @@ def photo_profile(self, photo, owner_id=None, crop_x=None, crop_y=None, crop_wid
115115
response = self.vk.method('photos.saveOwnerPhoto', response.json())
116116

117117
return response
118+
119+
def photo_chat(self, photo, chat_id):
120+
""" Загрузка и смена обложки в беседе
121+
:param photo: путь к изображению
122+
:param chat_id: ID беседы
123+
"""
124+
125+
values = {'chat_id': chat_id}
126+
url = self.vk.method('photos.getChatUploadServer', values)['upload_url']
127+
128+
photo_file = open_photos(photo)
129+
response = self.vk.http.post(url, files=photo_file)
130+
close_photos(photo_file)
131+
132+
response = self.vk.method('messages.setChatPhoto', response.json())
133+
134+
return response
118135

119136
def photo_wall(self, photos, user_id=None, group_id=None):
120137
""" Загрузка изображений на стену пользователя или в группу

0 commit comments

Comments
 (0)