Skip to content

Commit 3f82c5d

Browse files
committed
Add gift_count to Chat
1 parent b6a9607 commit 3f82c5d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

docs/source/releases/changes-in-this-fork.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Changes in this Fork
2626
| Scheme layer used: 198 |
2727
+------------------------+
2828

29+
- Added the ``gift_count`` to the :obj:`~pyrogram.types.Chat`.
2930
- Added the :meth:`~pyrogram.Client.get_similar_bots`.
3031
- Changed types in :obj:`~pyrogram.types.UpgradedGift`, :obj:`~pyrogram.types.UserGift`.
3132
- PR from upstream: `701 <https://github.com/pyrogram/pyrogram/pull/701>`_

pyrogram/types/user_and_chats/chat.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ class Chat(Object):
222222
can_enable_paid_reaction (``bool``, *optional*):
223223
True, if paid reaction can be enabled in the channel chat; for channels only.
224224
225+
gift_count (``int``, *optional*):
226+
Number of saved to profile gifts for other users or the total number of received gifts for the current user.
227+
Number of saved to profile gifts for channels without ``can_post_messages`` administrator right, otherwise, the total number of received gifts.
228+
225229
full_name (``str``, *property*):
226230
Full name of the other party in a private chat, for private chats and bots.
227231
@@ -289,6 +293,7 @@ def __init__(
289293
can_send_paid_media: bool = None,
290294
pending_join_request_count: int = None,
291295
can_enable_paid_reaction: bool = None,
296+
gift_count: int = None,
292297
_raw: Union[
293298
"raw.types.ChatInvite",
294299
"raw.types.Channel",
@@ -358,6 +363,7 @@ def __init__(
358363
self.can_send_paid_media = can_send_paid_media
359364
self.pending_join_request_count = pending_join_request_count
360365
self.can_enable_paid_reaction = can_enable_paid_reaction
366+
self.gift_count = gift_count
361367
self._raw = _raw
362368

363369
@staticmethod
@@ -617,6 +623,8 @@ async def _parse_full(client, chat_full: Union[raw.types.messages.ChatFull, raw.
617623

618624
if getattr(full_user, "wallpaper", None):
619625
parsed_chat.background = types.ChatBackground._parse(client, full_user.wallpaper)
626+
parsed_chat.gift_count = full_user.stargifts_count
627+
620628
else:
621629
full_chat = chat_full.full_chat
622630
chat_raw = chats[full_chat.id]
@@ -666,6 +674,7 @@ async def _parse_full(client, chat_full: Union[raw.types.messages.ChatFull, raw.
666674

667675
parsed_chat.can_send_paid_media = getattr(full_chat, "paid_media_allowed", None)
668676
parsed_chat.can_enable_paid_reaction = full_chat.paid_reactions_available
677+
parsed_chat.gift_count = full_chat.stargifts_count
669678

670679
parsed_chat.message_auto_delete_time = getattr(full_chat, "ttl_period")
671680

0 commit comments

Comments
 (0)