Skip to content

Commit 9688d33

Browse files
Added the class UserRating and the field rating to the class ChatFullInfo.
1 parent 913ff95 commit 9688d33

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

telebot/types.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,9 @@ class ChatFullInfo(JsonDeserializable):
748748
:param location: Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat.
749749
:type location: :class:`telebot.types.ChatLocation`
750750

751+
:param rating: Optional. For private chats, the rating of the user if any
752+
:type rating: :class:`telebot.types.UserRating`
753+
751754
:return: Instance of the class
752755
:rtype: :class:`telebot.types.ChatFullInfo`
753756
"""
@@ -779,6 +782,8 @@ def de_json(cls, json_string):
779782
obj['accepted_gift_types'] = AcceptedGiftTypes.de_json(obj['accepted_gift_types'])
780783
if 'parent_chat' in obj:
781784
obj['parent_chat'] = Chat.de_json(obj['parent_chat'])
785+
if 'rating' in obj:
786+
obj['rating'] = UserRating.de_json(obj['rating'])
782787
return cls(**obj)
783788

784789
def __init__(self, id, type, title=None, username=None, first_name=None,
@@ -795,7 +800,7 @@ def __init__(self, id, type, title=None, username=None, first_name=None,
795800
unrestrict_boost_count=None, custom_emoji_sticker_set_name=None, business_intro=None, business_location=None,
796801
business_opening_hours=None, personal_chat=None, birthdate=None,
797802
can_send_paid_media=None,
798-
accepted_gift_types=None, is_direct_messages=None, parent_chat=None, **kwargs):
803+
accepted_gift_types=None, is_direct_messages=None, parent_chat=None, rating=None, **kwargs):
799804
self.id: int = id
800805
self.type: str = type
801806
self.title: Optional[str] = title
@@ -843,6 +848,7 @@ def __init__(self, id, type, title=None, username=None, first_name=None,
843848
self.accepted_gift_types: AcceptedGiftTypes = accepted_gift_types
844849
self.is_direct_messages: Optional[bool] = is_direct_messages
845850
self.parent_chat: Optional[Chat] = parent_chat
851+
self.rating: Optional[UserRating] = rating
846852
@property
847853
def can_send_gift(self) -> bool:
848854
"""
@@ -13405,4 +13411,38 @@ def de_json(cls, json_string):
1340513411
return cls(**obj)
1340613412

1340713413

13414+
class UserRating(JsonDeserializable):
13415+
"""
13416+
This object describes the rating of a user based on their Telegram Star spendings.
13417+
13418+
Telegram documentation: https://core.telegram.org/bots/api#userrating
13419+
13420+
:param level: Current level of the user, indicating their reliability when purchasing digital goods and services. A higher level suggests a more trustworthy customer; a negative level is likely reason for concern.
13421+
:type level: :obj:`int`
13422+
13423+
:param rating: Numerical value of the user's rating; the higher the rating, the better
13424+
:type rating: :obj:`int`
13425+
13426+
:param current_level_rating: The rating value required to get the current level
13427+
:type current_level_rating: :obj:`int`
13428+
13429+
:param next_level_rating: Optional. The rating value required to get to the next level; omitted if the maximum level was reached
13430+
:type next_level_rating: :obj:`int`
13431+
13432+
:return: Instance of the class
13433+
:rtype: :class:`UserRating`
13434+
"""
13435+
def __init__(self, level: int, rating: int, current_level_rating: int,
13436+
next_level_rating: Optional[int] = None, **kwargs):
13437+
self.level: int = level
13438+
self.rating: int = rating
13439+
self.current_level_rating: int = current_level_rating
13440+
self.next_level_rating: Optional[int] = next_level_rating
13441+
13442+
@classmethod
13443+
def de_json(cls, json_string):
13444+
if json_string is None: return None
13445+
obj = cls.check_json(json_string)
13446+
return cls(**obj)
13447+
1340813448

0 commit comments

Comments
 (0)