Skip to content

Commit e459b8d

Browse files
committed
Merge remote-tracking branch 'KurimuzonAkuma/dev' into dev
2 parents bf0e912 + 9263a3b commit e459b8d

12 files changed

Lines changed: 545 additions & 303 deletions

File tree

compiler/docs/compiler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,7 @@ def get_title_list(s: str) -> list:
807807
UpgradedGiftAttributeIdModel
808808
UpgradedGiftAttributeIdSymbol
809809
UpgradedGiftAttributeIdBackdrop
810+
UpgradedGiftOriginalDetails
810811
InputChatPhoto
811812
InputChatPhotoPrevious
812813
InputChatPhotoStatic
@@ -1217,6 +1218,7 @@ def get_title_list(s: str) -> list:
12171218
PrivacyRuleType
12181219
GiftForResaleOrder
12191220
GiftPurchaseOfferState
1221+
GiftType
12201222
PaymentFormType
12211223
StickerType
12221224
MaskPointType

pyrogram/enums/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
from .gift_attribute_type import GiftAttributeType
4747
from .gift_for_resale_order import GiftForResaleOrder
4848
from .gift_purchase_offer_state import GiftPurchaseOfferState
49+
from .gift_type import GiftType
4950
from .mask_point_type import MaskPointType
5051
from .media_area_type import MediaAreaType
5152
from .stories_privacy_rules import StoriesPrivacyRules
@@ -85,6 +86,7 @@
8586
'GiftAttributeType',
8687
'GiftForResaleOrder',
8788
'GiftPurchaseOfferState',
89+
'GiftType',
8890
'MaskPointType',
8991
'MediaAreaType',
9092
'StoriesPrivacyRules',

pyrogram/enums/gift_type.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
3+
#
4+
# This file is part of Pyrogram.
5+
#
6+
# Pyrogram is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Pyrogram is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+
from enum import auto
20+
21+
from .auto_name import AutoName
22+
23+
24+
class GiftType(AutoName):
25+
"""Gift type enumeration used in :obj:`~pyrogram.types.Gift`."""
26+
27+
REGULAR = auto()
28+
"Gift is a regular gift"
29+
30+
UPGRADED = auto()
31+
"Gift is an upgraded gift"

pyrogram/methods/business/get_business_account_gifts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ async def get_business_account_gifts(
124124
chats = {i.id: i for i in r.chats}
125125

126126
user_star_gifts = [
127-
await types.Gift._parse_saved(self, gift, users, chats)
127+
await types.Gift._parse(self, gift, users, chats)
128128
for gift in r.gifts
129129
]
130130

pyrogram/methods/chats/set_upgraded_gift_colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async def set_upgraded_gift_colors(
2525
self: "pyrogram.Client",
2626
upgraded_gift_colors_id: int
2727
) -> bool:
28-
"""Update color
28+
"""Changes color scheme for the current user based on an owned or a hosted upgraded gift.
2929
3030
.. include:: /_includes/usable-by/users.rst
3131

pyrogram/methods/messages/summarize_message.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19+
from typing import Optional
20+
1921
import pyrogram
2022
from pyrogram import raw, types
2123

@@ -25,7 +27,7 @@ async def summarize_message(
2527
self: "pyrogram.Client",
2628
chat_id: str,
2729
message_id: int,
28-
translate_to_language_code: str,
30+
translate_to_language_code: Optional[str] = None,
2931
) -> "types.FormattedText":
3032
"""Summarizes content of the message with non-empty summary_language_code.
3133
@@ -40,12 +42,13 @@ async def summarize_message(
4042
message_id (``int``):
4143
Identifier of the message.
4244
43-
translate_to_language_code (``str``):
45+
translate_to_language_code (``str``, *optional*):
4446
Language code of the language to which the message is translated.
4547
Must be one of "af", "sq", "am", "ar", "hy", "az", "eu", "be", "bn", "bs", "bg", "ca", "ceb", "zh-CN", "zh", "zh-Hans", "zh-TW", "zh-Hant", "co", "hr", "cs", "da", "nl", "en", "eo", "et",
4648
"fi", "fr", "fy", "gl", "ka", "de", "el", "gu", "ht", "ha", "haw", "he", "iw", "hi", "hmn", "hu", "is", "ig", "id", "in", "ga", "it", "ja", "jv", "kn", "kk", "km", "rw", "ko",
4749
"ku", "ky", "lo", "la", "lv", "lt", "lb", "mk", "mg", "ms", "ml", "mt", "mi", "mr", "mn", "my", "ne", "no", "ny", "or", "ps", "fa", "pl", "pt", "pa", "ro", "ru", "sm", "gd", "sr",
4850
"st", "sn", "sd", "si", "sk", "sl", "so", "es", "su", "sw", "sv", "tl", "tg", "ta", "tt", "te", "th", "tr", "tk", "uk", "ur", "ug", "uz", "vi", "cy", "xh", "yi", "ji", "yo", "zu"
51+
Defaults to the client's language code.
4952
5053
Returns:
5154
:obj:`~pyrogram.types.FormattedText`: On success, information about the summarized text is returned.
@@ -54,7 +57,7 @@ async def summarize_message(
5457
raw.functions.messages.SummarizeText(
5558
peer=await self.resolve_peer(chat_id),
5659
id=message_id,
57-
to_lang=translate_to_language_code
60+
to_lang=translate_to_language_code or self.lang_code
5861
)
5962
)
6063

pyrogram/methods/payments/get_chat_gifts.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from typing import Optional, Union, AsyncGenerator
2020

2121
import pyrogram
22-
from pyrogram import raw, types
22+
from pyrogram import raw, types, utils
2323

2424

2525
class GetChatGifts:
@@ -95,6 +95,7 @@ async def get_chat_gifts(
9595
print(gift)
9696
"""
9797
peer = await self.resolve_peer(chat_id)
98+
raw_peer_id = utils.get_raw_peer_id(peer)
9899

99100
current = 0
100101
total = abs(limit) or (1 << 31) - 1
@@ -123,8 +124,10 @@ async def get_chat_gifts(
123124
users = {i.id: i for i in r.users}
124125
chats = {i.id: i for i in r.chats}
125126

127+
receiver = users.get(raw_peer_id) or chats.get(raw_peer_id)
128+
126129
user_star_gifts = [
127-
await types.Gift._parse_saved(self, gift, users, chats)
130+
await types.Gift._parse(self, gift, receiver, users, chats)
128131
for gift in r.gifts
129132
]
130133

pyrogram/methods/payments/get_upgraded_gift.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,6 @@ async def get_upgraded_gift(
6161
)
6262

6363
users = {i.id: i for i in r.users}
64+
chats = {i.id: i for i in r.chats}
6465

65-
return await types.Gift._parse_unique(self, r.gift, users)
66+
return await types.Gift._parse(self, r.gift, users, chats)

pyrogram/types/messages_and_media/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
from .upgraded_gift_attribute_id_model import UpgradedGiftAttributeIdModel
127127
from .upgraded_gift_attribute_id_symbol import UpgradedGiftAttributeIdSymbol
128128
from .upgraded_gift_attribute_id import UpgradedGiftAttributeId
129+
from .upgraded_gift_original_details import UpgradedGiftOriginalDetails
129130
from .upgraded_gift_purchase_offer import UpgradedGiftPurchaseOffer, UpgradedGiftPurchaseOfferRejected
130131
from .upgraded_gift_value_info import UpgradedGiftValueInfo
131132
from .venue import Venue
@@ -253,6 +254,7 @@
253254
"UpgradedGiftAttributeIdModel",
254255
"UpgradedGiftAttributeIdSymbol",
255256
"UpgradedGiftAttributeId",
257+
"UpgradedGiftOriginalDetails",
256258
"UpgradedGiftPurchaseOffer",
257259
"UpgradedGiftPurchaseOfferRejected",
258260
"UpgradedGiftValueInfo",

0 commit comments

Comments
 (0)