Add support for ApplyBoost service messages

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
KurimuzonAkuma 2024-02-20 11:05:32 +03:00 committed by wulan17
parent 26654b1945
commit ec19f4f6bb
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
2 changed files with 28 additions and 0 deletions

View file

@ -105,3 +105,6 @@ class MessageServiceType(AutoName):
GIVEAWAY_RESULT = auto() GIVEAWAY_RESULT = auto()
"Giveaway Result" "Giveaway Result"
BOOST_APPLY = auto()
"Boost apply"

View file

@ -367,6 +367,24 @@ class Message(Object, Update):
web_app_data (:obj:`~pyrogram.types.WebAppData`, *optional*): web_app_data (:obj:`~pyrogram.types.WebAppData`, *optional*):
Service message: web app data sent to the bot. Service message: web app data sent to the bot.
<<<<<<< HEAD
=======
gift_code (:obj:`~pyrogram.types.GiftCode`, *optional*):
Service message: gift code information.
requested_chats (:obj:`~pyrogram.types.RequestedChats`, *optional*):
Service message: requested chats information.
giveaway_launched (``bool``, *optional*):
Service message: giveaway launched.
chat_ttl_period (``int``, *optional*):
Service message: chat TTL period changed.
boosts_applied (``int``, *optional*):
Service message: how many boosts were applied.
>>>>>>> ccd9688e (Add support for ApplyBoost service messages)
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*): reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardMarkup` | :obj:`~pyrogram.types.ReplyKeyboardRemove` | :obj:`~pyrogram.types.ForceReply`, *optional*):
Additional interface options. An object for an inline keyboard, custom reply keyboard, Additional interface options. An object for an inline keyboard, custom reply keyboard,
instructions to remove reply keyboard or to force a reply from the user. instructions to remove reply keyboard or to force a reply from the user.
@ -439,6 +457,7 @@ class Message(Object, Update):
game: "types.Game" = None, game: "types.Game" = None,
giveaway: "types.Giveaway" = None, giveaway: "types.Giveaway" = None,
giveaway_result: "types.GiveawayResult" = None, giveaway_result: "types.GiveawayResult" = None,
boosts_applied: int = None,
story: Union["types.MessageStory", "types.Story"] = None, story: Union["types.MessageStory", "types.Story"] = None,
video: "types.Video" = None, video: "types.Video" = None,
voice: "types.Voice" = None, voice: "types.Voice" = None,
@ -540,6 +559,7 @@ class Message(Object, Update):
self.game = game self.game = game
self.giveaway = giveaway self.giveaway = giveaway
self.giveaway_result = giveaway_result self.giveaway_result = giveaway_result
self.boosts_applied = boosts_applied
self.story = story self.story = story
self.video = video self.video = video
self.voice = voice self.voice = voice
@ -688,6 +708,7 @@ class Message(Object, Update):
web_app_data = None web_app_data = None
giveaway_launched = None giveaway_launched = None
giveaway_result = None giveaway_result = None
boosts_applied = None
service_type = None service_type = None
@ -779,6 +800,9 @@ class Message(Object, Update):
elif isinstance(action, raw.types.MessageActionGiveawayResults): elif isinstance(action, raw.types.MessageActionGiveawayResults):
giveaway_result = await types.GiveawayResult._parse(client, action, True) giveaway_result = await types.GiveawayResult._parse(client, action, True)
service_type = enums.MessageServiceType.GIVEAWAY_RESULT service_type = enums.MessageServiceType.GIVEAWAY_RESULT
elif isinstance(action, raw.types.MessageActionBoostApply):
boosts_applied = action.boosts
service_type = enums.MessageServiceType.BOOST_APPLY
from_user = types.User._parse(client, users.get(user_id, None)) from_user = types.User._parse(client, users.get(user_id, None))
sender_chat = types.Chat._parse(client, message, users, chats, is_chat=False) if not from_user else None sender_chat = types.Chat._parse(client, message, users, chats, is_chat=False) if not from_user else None
@ -817,6 +841,7 @@ class Message(Object, Update):
web_app_data=web_app_data, web_app_data=web_app_data,
giveaway_launched=giveaway_launched, giveaway_launched=giveaway_launched,
giveaway_result=giveaway_result, giveaway_result=giveaway_result,
boosts_applied=boosts_applied,
raw=message, raw=message,
client=client client=client
# TODO: supergroup_chat_created # TODO: supergroup_chat_created