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 <[email protected]>
  • Loading branch information
yasirarism committed Jan 4, 2025
1 parent 20c55f3 commit 66e14d6
Show file tree
Hide file tree
Showing 9 changed files with 368 additions and 818 deletions.
2 changes: 1 addition & 1 deletion pyrogram/enums/message_service_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class MessageServiceType(AutoName):
GIFT_CODE = auto()
"Gift code"

USER_GIFT = auto()
STAR_GIFT = auto()
"Star gift"

SCREENSHOT_TAKEN = auto()
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"
]
]
11 changes: 2 additions & 9 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 @@ -908,7 +902,7 @@ async def _parse(
service_type = enums.MessageServiceType.GIFT_CODE
elif isinstance(action, (raw.types.MessageActionStarGift, raw.types.MessageActionStarGiftUnique)):
star_gift = await types.StarGift._parse_action(client, message, users)
service_type = enums.MessageServiceType.UserGift
service_type = enums.MessageServiceType.STAR_GIFT
elif isinstance(action, raw.types.MessageActionScreenshotTaken):
screenshot_taken = types.ScreenshotTaken()
service_type = enums.MessageServiceType.SCREENSHOT_TAKEN
Expand Down Expand Up @@ -949,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 @@ -5476,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 66e14d6

Please sign in to comment.