Skip to content

Commit bec87fa

Browse files
Fix setmyprofilephoto
1 parent 64e3479 commit bec87fa

4 files changed

Lines changed: 14 additions & 23 deletions

File tree

telebot/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5071,14 +5071,14 @@ def get_my_short_description(self, language_code: Optional[str]=None):
50715071
return types.BotShortDescription.de_json(
50725072
apihelper.get_my_short_description(self.token, language_code=language_code))
50735073

5074-
def set_my_profile_photo(self, photo: Any) -> bool:
5074+
def set_my_profile_photo(self, photo: types.InputProfilePhoto) -> bool:
50755075
"""
50765076
Use this method to change the profile photo of the bot. Returns True on success.
50775077
50785078
Telegram documentation: https://core.telegram.org/bots/api#setmyprofilephoto
50795079
5080-
:param photo: New profile photo for the bot, uploaded using multipart/form-data
5081-
:type photo: :obj:`typing.Union[file_like, str]`
5080+
:param photo: The new profile photo to set
5081+
:type photo: :class:`telebot.types.InputProfilePhoto`
50825082
50835083
:return: True on success.
50845084
:rtype: :obj:`bool`
@@ -7806,7 +7806,7 @@ def delete_sticker_from_set(self, sticker: str) -> bool:
78067806
78077807
:param sticker: File identifier of the sticker
78087808
:return: On success, True is returned.
7809-
:rtype: :obj:`bool`
7809+
:rtype: :obj:`bool`
78107810
"""
78117811
return apihelper.delete_sticker_from_set(self.token, sticker)
78127812

telebot/apihelper.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,14 +1538,9 @@ def get_my_name(token, language_code=None):
15381538

15391539
def set_my_profile_photo(token, photo):
15401540
method_url = r'setMyProfilePhoto'
1541-
files = None
15421541
payload = {}
1543-
if util.is_string(photo):
1544-
payload['photo'] = photo
1545-
elif util.is_pil_image(photo):
1546-
files = {'photo': util.pil_image_to_file(photo)}
1547-
else:
1548-
files = {'photo': photo}
1542+
photo_json, files = photo.convert_input_profile_photo()
1543+
payload['photo'] = photo_json
15491544
return _make_request(token, method_url, params=payload, files=files, method='post')
15501545

15511546
def delete_my_profile_photo(token):

telebot/async_telebot.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3007,7 +3007,7 @@ async def get_user_profile_audios(self, user_id: int, offset: Optional[int]=None
30073007
:return: If successful, returns a UserProfileAudios object.
30083008
:rtype: :class:`telebot.types.UserProfileAudios`
30093009
"""
3010-
return types.UserProfileAudios.de_json(await asyncio_helper.get_user_profile_audios(self.token, user_id, offset, limit))
3010+
return types.UserProfileAudios.de_json(await asyncio_helper.get_user_profile_audios(self.token, user_id, offset=offset, limit=limit))
30113011

30123012
async def set_user_emoji_status(self, user_id: int, emoji_status_custom_emoji_id: Optional[str]=None, emoji_status_expiration_date: Optional[int]=None) -> bool:
30133013
"""
@@ -6553,14 +6553,14 @@ async def get_my_name(self, language_code: Optional[str]=None):
65536553
result = await asyncio_helper.get_my_name(self.token, language_code)
65546554
return types.BotName.de_json(result)
65556555

6556-
async def set_my_profile_photo(self, photo: Any) -> bool:
6556+
async def set_my_profile_photo(self, photo: types.InputProfilePhoto) -> bool:
65576557
"""
65586558
Use this method to change the profile photo of the bot. Returns True on success.
65596559
65606560
Telegram documentation: https://core.telegram.org/bots/api#setmyprofilephoto
65616561
65626562
:param photo: InputProfilePhoto: The new profile photo to set
6563-
:type photo: :obj:`typing.Union[file_like, str]`
6563+
:type photo: :class:`telebot.types.InputProfilePhoto`
65646564
65656565
:return: True on success.
65666566
:rtype: :obj:`bool`
@@ -9238,8 +9238,8 @@ async def create_forum_topic(self,
92389238
chat_id: int, name: str, icon_color: Optional[int]=None,
92399239
icon_custom_emoji_id: Optional[str]=None) -> types.ForumTopic:
92409240
"""
9241-
Use this method to create a topic in a forum supergroup chat. The bot must be an administrator
9242-
in the chat for this to work and must have the can_manage_topics administrator rights.
9241+
Use this method to create a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot
9242+
must be an administrator in the chat for this to work and must have the can_manage_topics administrator right.
92439243
Returns information about the created topic as a ForumTopic object.
92449244
92459245
Telegram documentation: https://core.telegram.org/bots/api#createforumtopic

telebot/asyncio_helper.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,13 +1530,9 @@ async def get_my_name(token, language_code=None):
15301530
async def set_my_profile_photo(token, photo):
15311531
method_url = r'setMyProfilePhoto'
15321532
payload = {}
1533-
files = None
1534-
if util.is_string(photo):
1535-
payload['photo'] = photo
1536-
elif util.is_pil_image(photo):
1537-
files = {'photo': util.pil_image_to_file(photo)}
1538-
else:
1539-
files = {'photo': photo}
1533+
photo_json, files = photo.convert_input_profile_photo()
1534+
payload['photo'] = photo_json
1535+
15401536
return await _process_request(token, method_url, params=payload, files=files, method='post')
15411537

15421538
async def remove_my_profile_photo(token):

0 commit comments

Comments
 (0)