Skip to content

Commit

Permalink
pyrofork: Refactor StarGift and remove duplicate types
Browse files Browse the repository at this point in the history
Signed-off-by: Yasir Aris <git@yasir.id>

pyrofork: Refactor StarGift and remove duplicate types

Signed-off-by: Yasir Aris <git@yasir.id>
  • Loading branch information
yasirarism committed Jan 4, 2025
1 parent 4344f3f commit 4d3225c
Show file tree
Hide file tree
Showing 9 changed files with 366 additions and 756 deletions.
3 changes: 0 additions & 3 deletions pyrogram/enums/message_service_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ class MessageServiceType(AutoName):
GIFT_CODE = auto()
"Gift code"

USER_GIFT = auto()
"Star gift"

STAR_GIFT = auto()
"Star gift"

Expand Down
6 changes: 1 addition & 5 deletions pyrogram/types/messages_and_media/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
from .reaction import Reaction
from .read_participant import ReadParticipant
from .screenshot_taken import ScreenshotTaken
from .star_gift_attribute import StarGiftAttribute
from .star_gift import StarGift
from .sticker import Sticker
from .stickerset import StickerSet
from .stories_privacy_rules import StoriesPrivacyRules
Expand Down Expand Up @@ -117,8 +115,6 @@
"MessageStory",
"ReadParticipant",
"ScreenshotTaken",
"StarGiftAttribute",
"StarGift",
"Story",
"StoryDeleted",
"StorySkipped",
Expand All @@ -129,4 +125,4 @@
"Wallpaper",
"WallpaperSettings",
"TranslatedText"
]
]
12 changes: 1 addition & 11 deletions pyrogram/types/messages_and_media/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,6 @@ class Message(Object, Update):
Service message: gift code information.
Contains a `Telegram Premium giftcode link <https://core.telegram.org/api/links#premium-giftcode-links>`_.
user_gift (:obj:`~pyrogram.types.UserGift`, *optional*):
Service message: Represents a gift received by a user.
star_gift (:obj:`~pyrogram.types.StarGift`, *optional*):
Service message: star gift information.
Expand Down Expand Up @@ -501,7 +498,6 @@ def __init__(
chat_wallpaper_updated: "types.ChatWallpaper" = None,
contact_registered: "types.ContactRegistered" = None,
gift_code: "types.GiftCode" = None,
user_gift: "types.UserGift" = None,
star_gift: "types.StarGift" = None,
screenshot_taken: "types.ScreenshotTaken" = None,
invoice: "types.Invoice" = None,
Expand Down Expand Up @@ -623,7 +619,6 @@ def __init__(
self.chat_wallpaper_updated = chat_wallpaper_updated
self.contact_registered = contact_registered
self.gift_code = gift_code
self.user_gift = user_gift
self.star_gift = star_gift
self.screenshot_taken = screenshot_taken
self.invoice = invoice
Expand Down Expand Up @@ -788,7 +783,6 @@ async def _parse(
chat_wallpaper_updated = None
contact_registered = None
gift_code = None
user_gift = None
star_gift = None
screenshot_taken = None

Expand Down Expand Up @@ -906,9 +900,6 @@ async def _parse(
elif isinstance(action, raw.types.MessageActionGiftCode):
gift_code = types.GiftCode._parse(client, action, chats)
service_type = enums.MessageServiceType.GIFT_CODE
elif isinstance(action, raw.types.MessageActionStarGift):
user_gift = await types.UserGift._parse_action(client, message, users)
service_type = enums.MessageServiceType.USER_GIFT
elif isinstance(action, (raw.types.MessageActionStarGift, raw.types.MessageActionStarGiftUnique)):
star_gift = await types.StarGift._parse_action(client, message, users)
service_type = enums.MessageServiceType.STAR_GIFT
Expand Down Expand Up @@ -952,7 +943,6 @@ async def _parse(
giveaway_launched=giveaway_launched,
giveaway_result=giveaway_result,
successful_payment=successful_payment,
user_gift=user_gift,
star_gift=star_gift,
payment_refunded=payment_refunded,
boosts_applied=boosts_applied,
Expand Down Expand Up @@ -5479,4 +5469,4 @@ async def translate(
chat_id=self.chat.id,
message_ids=self.id,
to_language_code=to_language_code
)
)
Loading

0 comments on commit 4d3225c

Please sign in to comment.