Skip to content

Commit

Permalink
Added the method setUserEmojiStatus. The user must allow the bot to …
Browse files Browse the repository at this point in the history
…manage their emoji status.
  • Loading branch information
coder2020official committed Nov 17, 2024
1 parent 8eb5d10 commit e55b097
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
20 changes: 20 additions & 0 deletions telebot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,26 @@ def get_user_profile_photos(self, user_id: int, offset: Optional[int]=None,
apihelper.get_user_profile_photos(self.token, user_id, offset=offset, limit=limit)
)

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:
"""
Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success.
Telegram documentation: https://core.telegram.org/bots/api#setuseremojistatus
:param user_id: Unique identifier of the target user
:type user_id: :obj:`int`
:param emoji_status_custom_emoji_id: Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.
:type emoji_status_custom_emoji_id: :obj:`str`
:param emoji_status_expiration_date: Expiration date of the emoji status, if any
:type emoji_status_expiration_date: :obj:`int`
:return: :obj:`bool`
"""
return apihelper.set_user_emoji_status(
self.token, user_id, emoji_status_custom_emoji_id=emoji_status_custom_emoji_id, emoji_status_expiration_date=emoji_status_expiration_date)


def get_chat(self, chat_id: Union[int, str]) -> types.ChatFullInfo:
"""
Expand Down
10 changes: 10 additions & 0 deletions telebot/apihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,16 @@ def get_user_profile_photos(token, user_id, offset=None, limit=None):
payload['limit'] = limit
return _make_request(token, method_url, params=payload)


def set_user_emoji_status(token, user_id, emoji_status_custom_emoji_id=None, emoji_status_expiration_date=None):
method_url = r'setUserEmojiStatus'
payload = {'user_id': user_id}
if emoji_status_custom_emoji_id:
payload['emoji_status_custom_emoji_id'] = emoji_status_custom_emoji_id
if emoji_status_expiration_date:
payload['emoji_status_expiration_date'] = emoji_status_expiration_date
return _make_request(token, method_url, params=payload)

def set_message_reaction(token, chat_id, message_id, reaction=None, is_big=None):
method_url = r'setMessageReaction'
payload = {'chat_id': chat_id, 'message_id': message_id}
Expand Down
20 changes: 20 additions & 0 deletions telebot/async_telebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2987,6 +2987,26 @@ async def get_user_profile_photos(self, user_id: int, offset: Optional[int]=None
"""
result = await asyncio_helper.get_user_profile_photos(self.token, user_id, offset, limit)
return types.UserProfilePhotos.de_json(result)

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:
"""
Use this method to change the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess.
Telegram documentation: https://core.telegram.org/bots/api#setuseremojistatus
:param user_id: Unique identifier of the target user
:type user_id: :obj:`int`
:param emoji_status_custom_emoji_id: Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.
:type emoji_status_custom_emoji_id: :obj:`str`, optional
:param emoji_status_expiration_date: Expiration date of the emoji status, if any
:type emoji_status_expiration_date: :obj:`int`, optional
:return: :obj:`bool`
"""
result = await asyncio_helper.set_user_emoji_status(self.token, user_id, emoji_status_custom_emoji_id, emoji_status_expiration_date)
return result

async def get_chat(self, chat_id: Union[int, str]) -> types.ChatFullInfo:
"""
Expand Down
10 changes: 10 additions & 0 deletions telebot/asyncio_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,16 @@ async def get_user_profile_photos(token, user_id, offset=None, limit=None):
payload['limit'] = limit
return await _process_request(token, method_url, params=payload)


async def set_user_emoji_status(token, user_id, emoji_status_custom_emoji_id=None, emoji_status_expiration_date=None):
method_url = r'setUserEmojiStatus'
payload = {'user_id': user_id}
if emoji_status_custom_emoji_id:
payload['emoji_status_custom_emoji_id'] = emoji_status_custom_emoji_id
if emoji_status_expiration_date:
payload['emoji_status_expiration_date'] = emoji_status_expiration_date
return await _process_request(token, method_url, params=payload)

async def set_message_reaction(token, chat_id, message_id, reaction=None, is_big=None):
method_url = r'setMessageReaction'
payload = {'chat_id': chat_id, 'message_id': message_id}
Expand Down

0 comments on commit e55b097

Please sign in to comment.