Skip to content

Commit

Permalink
Update API Scheme to Layer 190
Browse files Browse the repository at this point in the history
  • Loading branch information
SpEcHiDe authored Oct 14, 2024
1 parent eeec73b commit f0da2e6
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 8 deletions.
8 changes: 4 additions & 4 deletions compiler/api/source/main_api.tl
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ messageActionSetChatTheme#aa786345 emoticon:string = MessageAction;
messageActionChatJoinedByRequest#ebbca3cb = MessageAction;
messageActionWebViewDataSentMe#47dd8079 text:string data:string = MessageAction;
messageActionWebViewDataSent#b4c38cb5 text:string = MessageAction;
messageActionGiftPremium#c83d6aec flags:# currency:string amount:long months:int crypto_currency:flags.0?string crypto_amount:flags.0?long = MessageAction;
messageActionGiftPremium#6c6274fa flags:# currency:string amount:long months:int crypto_currency:flags.0?string crypto_amount:flags.0?long message:flags.1?TextWithEntities = MessageAction;
messageActionTopicCreate#d999256 flags:# title:string icon_color:int icon_emoji_id:flags.0?long = MessageAction;
messageActionTopicEdit#c0944820 flags:# title:flags.0?string icon_emoji_id:flags.1?long closed:flags.2?Bool hidden:flags.3?Bool = MessageAction;
messageActionSuggestProfilePhoto#57de635e photo:Photo = MessageAction;
messageActionRequestedPeer#31518e9b button_id:int peers:Vector<Peer> = MessageAction;
messageActionSetChatWallPaper#5060a3f4 flags:# same:flags.0?true for_both:flags.1?true wallpaper:WallPaper = MessageAction;
messageActionGiftCode#678c2e09 flags:# via_giveaway:flags.0?true unclaimed:flags.2?true boost_peer:flags.1?Peer months:int slug:string currency:flags.2?string amount:flags.2?long crypto_currency:flags.3?string crypto_amount:flags.3?long = MessageAction;
messageActionGiftCode#56d03994 flags:# via_giveaway:flags.0?true unclaimed:flags.2?true boost_peer:flags.1?Peer months:int slug:string currency:flags.2?string amount:flags.2?long crypto_currency:flags.3?string crypto_amount:flags.3?long message:flags.4?TextWithEntities = MessageAction;
messageActionGiveawayLaunch#a80f51e4 flags:# stars:flags.0?long = MessageAction;
messageActionGiveawayResults#87e2f155 flags:# stars:flags.0?true winners_count:int unclaimed_count:int = MessageAction;
messageActionBoostApply#cc02aa6d boosts:int = MessageAction;
Expand Down Expand Up @@ -1526,7 +1526,7 @@ help.premiumPromo#5334759c status_text:string status_entities:Vector<MessageEnti

inputStorePaymentPremiumSubscription#a6751e66 flags:# restore:flags.0?true upgrade:flags.1?true = InputStorePaymentPurpose;
inputStorePaymentGiftPremium#616f7fe8 user_id:InputUser currency:string amount:long = InputStorePaymentPurpose;
inputStorePaymentPremiumGiftCode#a3805f3f flags:# users:Vector<InputUser> boost_peer:flags.0?InputPeer currency:string amount:long = InputStorePaymentPurpose;
inputStorePaymentPremiumGiftCode#fb790393 flags:# users:Vector<InputUser> boost_peer:flags.0?InputPeer currency:string amount:long message:flags.1?TextWithEntities = InputStorePaymentPurpose;
inputStorePaymentPremiumGiveaway#160544ca flags:# only_new_subscribers:flags.0?true winners_are_visible:flags.3?true boost_peer:InputPeer additional_peers:flags.1?Vector<InputPeer> countries_iso2:flags.2?Vector<string> prize_description:flags.4?string random_id:long until_date:int currency:string amount:long = InputStorePaymentPurpose;
inputStorePaymentStarsTopup#dddd0f56 stars:long currency:string amount:long = InputStorePaymentPurpose;
inputStorePaymentStarsGift#1d741ef7 user_id:InputUser stars:long currency:string amount:long = InputStorePaymentPurpose;
Expand Down Expand Up @@ -2623,4 +2623,4 @@ test.parseInputAppEvent = InputAppEvent;
// invokeWithGooglePlayIntegrityPrefix#1df92984 nonce:string token:string = Error;
// invokeWithApnsSecretPrefix#0dae54f8 nonce:string secret:string = Error;

// LAYER 189
// LAYER 190
6 changes: 6 additions & 0 deletions docs/source/releases/changes-in-this-fork.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ it can take advantage of new goodies!

If you found any issue or have any suggestions, feel free to make `an issue <https://github.com/TelegramPlayGround/pyrogram/issues>`_ on github.

+------------------------+
| Scheme layer used: 190 |
+------------------------+

- View `new and changed <https://telegramplayground.github.io/TG-APIs/TL/diff/tdlib.html?from=189&to=190>`__ `raw API methods <https://telegramplayground.github.io/TG-APIs/TL/diff/tdesktop.html?from=189&to=190>`__.

+------------------------+
| Scheme layer used: 189 |
+------------------------+
Expand Down
51 changes: 49 additions & 2 deletions pyrogram/types/messages_and_media/gift_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from pyrogram import raw, types, utils
from ..object import Object
from .message import Str


class GiftCode(Object):
Expand All @@ -42,6 +43,24 @@ class GiftCode(Object):
You can combine it with `t.me/giftcode/{slug}`
to get link for this gift.
currency (``str``):
Currency for the paid amount
amount (``int``):
The paid amount, in the smallest units of the currency
cryptocurrency (``str``):
Cryptocurrency used to pay for the gift; may be empty if none
cryptocurrency_amount (``int``):
The paid amount, in the smallest units of the cryptocurrency; 0 if none
caption (``str``, *optional*):
Text message chosen by the sender.
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`, *optional*):
Entities of the text message.
link (``str``, *property*):
Generate a link to this gift code.
"""
Expand All @@ -53,7 +72,13 @@ def __init__(
is_unclaimed: bool,
boosted_chat: "types.Chat",
premium_subscription_month_count: int,
slug: str
slug: str,
currency: str = None,
amount: int = None,
cryptocurrency: str = None,
cryptocurrency_amount: int = None,
caption: str = None,
caption_entities: List["types.MessageEntity"] = None
):
super().__init__()

Expand All @@ -62,6 +87,12 @@ def __init__(
self.boosted_chat = boosted_chat
self.premium_subscription_month_count = premium_subscription_month_count
self.slug = slug
self.currency = currency
self.amount = amount
self.cryptocurrency = cryptocurrency
self.cryptocurrency_amount = cryptocurrency_amount
self.caption = caption
self.caption_entities = caption_entities

@staticmethod
def _parse(
Expand All @@ -73,14 +104,30 @@ def _parse(
utils.get_raw_peer_id(giftcode.boost_peer)
)

caption = None
caption_entities = []
if giftcode.message:
caption_entities = [
types.MessageEntity._parse(client, entity, {})
for entity in giftcode.message.entities
]
caption_entities = types.List(filter(lambda x: x is not None, caption_entities))
caption = Str(giftcode.message.text).init(caption_entities) or None

return GiftCode(
via_giveaway=giftcode.via_giveaway,
is_unclaimed=giftcode.unclaimed,
boosted_chat=types.Chat._parse_chat(
client, peer
) if peer else None,
premium_subscription_month_count=giftcode.months,
slug=giftcode.slug
slug=giftcode.slug,
currency=giftcode.currency,
amount=giftcode.amount,
cryptocurrency=getattr(giftcode, "crypto_currency", None),
cryptocurrency_amount=getattr(giftcode, "crypto_amount", None),
caption=caption,
caption_entities=caption_entities
)

@property
Expand Down
28 changes: 26 additions & 2 deletions pyrogram/types/messages_and_media/gifted_premium.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from pyrogram import raw, types
from ..object import Object
from .message import Str


class GiftedPremium(Object):
Expand Down Expand Up @@ -47,6 +48,12 @@ class GiftedPremium(Object):
sticker (:obj:`~pyrogram.types.Sticker`):
A sticker to be shown in the message; may be null if unknown
caption (``str``, *optional*):
Text message chosen by the sender.
caption_entities (List of :obj:`~pyrogram.types.MessageEntity`, *optional*):
Entities of the text message.
"""

def __init__(
Expand All @@ -59,6 +66,8 @@ def __init__(
cryptocurrency_amount: int = None,
month_count: int = None,
sticker: "types.Sticker" = None,
caption: str = None,
caption_entities: List["types.MessageEntity"] = None
):
super().__init__()

Expand All @@ -69,7 +78,9 @@ def __init__(
self.cryptocurrency_amount = cryptocurrency_amount
self.month_count = month_count
self.sticker = sticker

self.caption = caption
self.caption_entities = caption_entities

@staticmethod
async def _parse(
client,
Expand All @@ -81,12 +92,25 @@ async def _parse(
raw.types.InputStickerSetPremiumGifts()
)
sticker = choice(stickers)

caption = None
caption_entities = []
if gifted_premium.message:
caption_entities = [
types.MessageEntity._parse(client, entity, {})
for entity in gifted_premium.message.entities
]
caption_entities = types.List(filter(lambda x: x is not None, caption_entities))
caption = Str(gifted_premium.message.text).init(caption_entities) or None

return GiftedPremium(
gifter_user_id=gifter_user_id,
currency=gifted_premium.currency,
amount=gifted_premium.amount,
cryptocurrency=getattr(gifted_premium, "crypto_currency", None),
cryptocurrency_amount=getattr(gifted_premium, "crypto_amount", None),
month_count=gifted_premium.months,
sticker=sticker
sticker=sticker,
caption=caption,
caption_entities=caption_entities
)

0 comments on commit f0da2e6

Please sign in to comment.