Pyrofork: Add GiveawayLaunched MessageService type

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2023-12-28 20:02:02 +07:00
parent 16390c3eff
commit ad501858ce
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
5 changed files with 44 additions and 1 deletions

View file

@ -464,6 +464,7 @@ def pyrogram_api():
StickerSet
Game
Giveaway
GiveawayLaunched
GiveawayResult
MessageStory
WebPage

View file

@ -100,5 +100,8 @@ class MessageServiceType(AutoName):
WEB_APP_DATA = auto()
"Web app data"
GIVEAWAY_LAUNCHED = auto()
"Giveaway Launch"
GIVEAWAY_RESULT = auto()
"Giveaway Result"

View file

@ -23,6 +23,7 @@ from .dice import Dice
from .document import Document
from .game import Game
from .giveaway import Giveaway
from .giveaway_launched import GiveawayLaunched
from .giveaway_result import GiveawayResult
from .location import Location
from .media_area import MediaArea
@ -57,7 +58,7 @@ from .story_views import StoryViews
from .exported_story_link import ExportedStoryLink
__all__ = [
"Animation", "Audio", "Contact", "Document", "Game", "Giveaway", "GiveawayResult", "Location", "MediaArea", "MediaAreaChannelPost", "MediaAreaCoordinates", "Message", "MessageEntity", "Photo", "Thumbnail",
"Animation", "Audio", "Contact", "Document", "Game", "Giveaway", "GiveawayLaunched", "GiveawayResult", "Location", "MediaArea", "MediaAreaChannelPost", "MediaAreaCoordinates", "Message", "MessageEntity", "Photo", "Thumbnail",
"StrippedThumbnail", "Poll", "PollOption", "Sticker", "StickerSet", "Venue", "Video", "VideoNote", "Voice", "WebPage", "WebPageEmpty", "WebPagePreview", "Dice",
"Reaction", "WebAppData", "MessageReactions", "MessageStory", "Story", "StoryDeleted", "StorySkipped", "StoryViews", "StoryForwardHeader", "StoriesPrivacyRules", "ExportedStoryLink"
]

View file

@ -0,0 +1,28 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
#
# This file is part of Pyrofork.
#
# Pyrofork is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrofork is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from ..object import Object
class GiveawayLaunched(Object):
"""A service message about a giveaway started in the channel.
Currently holds no information.
"""
def __init__(self):
super().__init__()

View file

@ -340,6 +340,9 @@ class Message(Object, Update):
general_topic_unhidden (:obj:`~pyrogram.types.GeneralTopicUnhidden`, *optional*):
Service message: forum general topic unhidden
giveaway_launcheded (:obj:`~pyrogram.types.GiveawayLaunched`, *optional*):
Service message: giveaway launched.
video_chat_scheduled (:obj:`~pyrogram.types.VideoChatScheduled`, *optional*):
Service message: voice chat scheduled.
@ -453,6 +456,7 @@ class Message(Object, Update):
forum_topic_edited: "types.ForumTopicEdited" = None,
general_topic_hidden: "types.GeneralTopicHidden" = None,
general_topic_unhidden: "types.GeneralTopicUnhidden" = None,
giveaway_launched: "types.GiveawayLauncheded" = None,
video_chat_scheduled: "types.VideoChatScheduled" = None,
video_chat_started: "types.VideoChatStarted" = None,
video_chat_ended: "types.VideoChatEnded" = None,
@ -550,6 +554,7 @@ class Message(Object, Update):
self.forum_topic_edited = forum_topic_edited
self.general_topic_hidden = general_topic_hidden
self.general_topic_unhidden = general_topic_unhidden
self.giveaway_launched = giveaway_launched
self.video_chat_scheduled = video_chat_scheduled
self.video_chat_started = video_chat_started
self.video_chat_ended = video_chat_ended
@ -655,6 +660,7 @@ class Message(Object, Update):
video_chat_ended = None
video_chat_members_invited = None
web_app_data = None
giveaway_launched = None
giveaway_result = None
service_type = None
@ -738,6 +744,9 @@ class Message(Object, Update):
elif isinstance(action, raw.types.MessageActionWebViewDataSentMe):
web_app_data = types.WebAppData._parse(action)
service_type = enums.MessageServiceType.WEB_APP_DATA
elif isinstance(action, raw.types.MessageActionGiveawayLaunch):
giveaway_launched = types.GiveawayLaunched()
service_type = enums.MessageServiceType.GIVEAWAY_LAUNCHED
elif isinstance(action, raw.types.MessageActionGiveawayResults):
giveaway_result = await types.GiveawayResult._parse(client, action, True)
service_type = enums.MessageServiceType.GIVEAWAY_RESULT
@ -777,6 +786,7 @@ class Message(Object, Update):
video_chat_ended=video_chat_ended,
video_chat_members_invited=video_chat_members_invited,
web_app_data=web_app_data,
giveaway_launched=giveaway_launched,
giveaway_result=giveaway_result,
client=client
# TODO: supergroup_chat_created