mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
pyrofork: Add some missings service messages
CHAT_THEME_UPDATED CHAT_WALLPAPER_UPDATED CONTACT_REGISTERED GIFT_CODE SCREENSHOT_TAKEN Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
9697a7f3cd
commit
a598ab6144
11 changed files with 552 additions and 4 deletions
|
|
@ -531,6 +531,14 @@ def pyrogram_api():
|
|||
Reaction
|
||||
MessageReactionUpdated
|
||||
MessageReactionCountUpdated
|
||||
ExportedStoryLink
|
||||
ChatTheme
|
||||
ChatWallpaper
|
||||
ContactRegistered
|
||||
GiftCode
|
||||
ScreenshotTaken
|
||||
Wallpaper
|
||||
WallpaperSettings
|
||||
""",
|
||||
stories="""
|
||||
Stories
|
||||
|
|
|
|||
|
|
@ -113,4 +113,19 @@ class MessageServiceType(AutoName):
|
|||
"Payment refunded"
|
||||
|
||||
BOT_ALLOWED = auto()
|
||||
"Bot allowed"
|
||||
"Bot allowed"
|
||||
|
||||
CHAT_THEME_UPDATED = auto()
|
||||
"Chat theme updated"
|
||||
|
||||
CHAT_WALLPAPER_UPDATED = auto()
|
||||
"Chat wallpaper updated"
|
||||
|
||||
CONTACT_REGISTERED = auto()
|
||||
"Contact registered"
|
||||
|
||||
GIFT_CODE = auto()
|
||||
"Gift code"
|
||||
|
||||
SCREENSHOT_TAKEN = auto()
|
||||
"Screenshot taken"
|
||||
|
|
|
|||
|
|
@ -20,10 +20,14 @@
|
|||
from .animation import Animation
|
||||
from .audio import Audio
|
||||
from .available_effect import AvailableEffect
|
||||
from .chat_theme import ChatTheme
|
||||
from .chat_wallpaper import ChatWallpaper
|
||||
from .contact import Contact
|
||||
from .contact_registered import ContactRegistered
|
||||
from .dice import Dice
|
||||
from .document import Document
|
||||
from .game import Game
|
||||
from .gift_code import GiftCode
|
||||
from .gifted_premium import GiftedPremium
|
||||
from .giveaway import Giveaway
|
||||
from .giveaway_launched import GiveawayLaunched
|
||||
|
|
@ -39,6 +43,7 @@ from .photo import Photo
|
|||
from .poll import Poll
|
||||
from .poll_option import PollOption
|
||||
from .reaction import Reaction
|
||||
from .screenshot_taken import ScreenshotTaken
|
||||
from .sticker import Sticker
|
||||
from .stickerset import StickerSet
|
||||
from .stories_privacy_rules import StoriesPrivacyRules
|
||||
|
|
@ -63,9 +68,61 @@ from .story_forward_header import StoryForwardHeader
|
|||
from .story_skipped import StorySkipped
|
||||
from .story_views import StoryViews
|
||||
from .exported_story_link import ExportedStoryLink
|
||||
from .wallpaper import Wallpaper
|
||||
from .wallpaper_settings import WallpaperSettings
|
||||
|
||||
__all__ = [
|
||||
"Animation", "Audio", "AvailableEffect", "Contact", "Document", "Game", "GiftedPremium", "Giveaway", "GiveawayLaunched", "GiveawayResult", "LabeledPrice", "Location", "MediaArea", "MediaAreaChannelPost", "MediaAreaCoordinates", "Message", "MessageEntity", "Photo", "Thumbnail",
|
||||
"StrippedThumbnail", "Poll", "PollOption", "Sticker", "StickerSet", "Venue", "Video", "VideoNote", "Voice", "WebPage", "WebPageEmpty", "WebPagePreview", "Dice",
|
||||
"Reaction", "WebAppData", "MessageReactions", "MessageReactionUpdated", "MessageReactionCountUpdated", "MessageReactor", "MessageStory", "Story", "StoryDeleted", "StorySkipped", "StoryViews", "StoryForwardHeader", "StoriesPrivacyRules", "ExportedStoryLink"
|
||||
"Animation",
|
||||
"Audio",
|
||||
"AvailableEffect",
|
||||
"ChatTheme",
|
||||
"ChatWallpaper",
|
||||
"Contact",
|
||||
"ContactRegistered",
|
||||
"Document",
|
||||
"Game",
|
||||
"GiftCode",
|
||||
"GiftedPremium",
|
||||
"Giveaway",
|
||||
"GiveawayLaunched",
|
||||
"GiveawayResult",
|
||||
"LabeledPrice",
|
||||
"Location",
|
||||
"MediaArea",
|
||||
"MediaAreaChannelPost",
|
||||
"MediaAreaCoordinates",
|
||||
"Message",
|
||||
"MessageEntity",
|
||||
"Photo",
|
||||
"Thumbnail",
|
||||
"StrippedThumbnail",
|
||||
"Poll",
|
||||
"PollOption",
|
||||
"Sticker",
|
||||
"StickerSet",
|
||||
"Venue",
|
||||
"Video",
|
||||
"VideoNote",
|
||||
"Voice",
|
||||
"WebPage",
|
||||
"WebPageEmpty",
|
||||
"WebPagePreview",
|
||||
"Dice",
|
||||
"Reaction",
|
||||
"WebAppData",
|
||||
"MessageReactions",
|
||||
"MessageReactionUpdated",
|
||||
"MessageReactionCountUpdated",
|
||||
"MessageReactor",
|
||||
"MessageStory",
|
||||
"ScreenshotTaken",
|
||||
"Story",
|
||||
"StoryDeleted",
|
||||
"StorySkipped",
|
||||
"StoryViews",
|
||||
"StoryForwardHeader",
|
||||
"StoriesPrivacyRules",
|
||||
"ExportedStoryLink",
|
||||
"Wallpaper",
|
||||
"WallpaperSettings"
|
||||
]
|
||||
|
|
|
|||
38
pyrogram/types/messages_and_media/chat_theme.py
Normal file
38
pyrogram/types/messages_and_media/chat_theme.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# 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
|
||||
from pyrogram import raw
|
||||
|
||||
class ChatTheme(Object):
|
||||
"""A service message about a chat theme.
|
||||
|
||||
parameters:
|
||||
emoticon (``str``):
|
||||
The emoticon of the chat theme.
|
||||
"""
|
||||
|
||||
def __init__(self, emoticon: str):
|
||||
super().__init__()
|
||||
self.emoticon = emoticon
|
||||
|
||||
@staticmethod
|
||||
def _parse(chat_theme: "raw.types.MessageActionSetChatTheme") -> "ChatTheme":
|
||||
return ChatTheme(
|
||||
emoticon=getattr(chat_theme, "emoticon", None)
|
||||
)
|
||||
55
pyrogram/types/messages_and_media/chat_wallpaper.py
Normal file
55
pyrogram/types/messages_and_media/chat_wallpaper.py
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
# 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/>.
|
||||
|
||||
import pyrogram
|
||||
|
||||
from ..object import Object
|
||||
from pyrogram import raw, types
|
||||
|
||||
class ChatWallpaper(Object):
|
||||
"""A service message about a chat wallpaper.
|
||||
|
||||
parameters:
|
||||
wallpaper (:obj:`types.Wallpaper`):
|
||||
The chat wallpaper.
|
||||
|
||||
is_same (``bool``, *optional*):
|
||||
True, if the chat wallpaper is the same as the previous one.
|
||||
|
||||
is_both (``bool``, *optional*):
|
||||
True, if the chat wallpaper is for both side.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
wallpaper: "types.Wallpaper",
|
||||
is_same: bool = None,
|
||||
is_both: bool = None
|
||||
):
|
||||
super().__init__()
|
||||
self.wallpaper = wallpaper
|
||||
self.is_same = is_same
|
||||
self.is_both = is_both
|
||||
|
||||
@staticmethod
|
||||
def _parse(client: "pyrogram.Client", chat_wallpaper: "raw.types.ChatWallpaper") -> "ChatWallpaper":
|
||||
return ChatWallpaper(
|
||||
wallpaper=types.Wallpaper._parse(client, chat_wallpaper.wallpaper),
|
||||
is_same=getattr(chat_wallpaper, "is_same", None),
|
||||
is_both=getattr(chat_wallpaper, "is_both", None)
|
||||
)
|
||||
29
pyrogram/types/messages_and_media/contact_registered.py
Normal file
29
pyrogram/types/messages_and_media/contact_registered.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# 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 ContactRegistered(Object):
|
||||
"""A service message about a contact registered.
|
||||
|
||||
Currently holds no information.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
97
pyrogram/types/messages_and_media/gift_code.py
Normal file
97
pyrogram/types/messages_and_media/gift_code.py
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
# 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/>.
|
||||
|
||||
import pyrogram
|
||||
|
||||
from ..object import Object
|
||||
from pyrogram import types, utils
|
||||
|
||||
|
||||
class GiftCode(Object):
|
||||
"""A service message about a gift code.
|
||||
|
||||
parameters:
|
||||
months (``int``):
|
||||
How long the telegram premium last (in month).
|
||||
|
||||
slug (``str``):
|
||||
The slug of the gift code.
|
||||
|
||||
is_giveaway (``bool``, *optional*):
|
||||
True, if the gift code is from a giveaway.
|
||||
|
||||
is_unclaimed (``bool``, *optional*):
|
||||
True, if the gift code is unclaimed.
|
||||
|
||||
boosted_chat (:obj:`~pyrogram.types.Chat`, *optional*):
|
||||
The chat that the gift code boost.
|
||||
|
||||
currency (``str``, *optional*):
|
||||
The currency of the gift code.
|
||||
|
||||
amount (``int``, *optional*):
|
||||
The amount of the gift code.
|
||||
|
||||
crypto_currency (``str``, *optional*):
|
||||
The crypto currency of the gift code.
|
||||
|
||||
crypto_amount (``int``, *optional*):
|
||||
The crypto amount of the gift code.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
months: int,
|
||||
slug: str,
|
||||
is_giveaway: bool = None,
|
||||
is_unclaimed: bool = None,
|
||||
boosted_chat: "types.Chat" = None,
|
||||
currency: str = None,
|
||||
amount: int = None,
|
||||
crypto_currency: str = None,
|
||||
crypto_amount: int = None
|
||||
):
|
||||
super().__init__()
|
||||
self.months = months
|
||||
self.slug = slug
|
||||
self.is_giveaway = is_giveaway
|
||||
self.is_unclaimed = is_unclaimed
|
||||
self.boosted_chat = boosted_chat
|
||||
self.currency = currency
|
||||
self.amount = amount
|
||||
self.crypto_currency = crypto_currency
|
||||
self.crypto_amount = crypto_amount
|
||||
|
||||
@staticmethod
|
||||
def _parse(client: "pyrogram.Client", gift_code: "types.GiftCode", chats: dict,) -> "GiftCode":
|
||||
boosted_chat = None
|
||||
boosted_chat_raw = chats.get(utils.get_raw_peer_id(gift_code.boost_peer), None)
|
||||
if boosted_chat_raw:
|
||||
boosted_chat = types.Chat._parse_channel_chat(client, boosted_chat_raw)
|
||||
|
||||
return GiftCode(
|
||||
months=gift_code.months,
|
||||
slug=gift_code.slug,
|
||||
is_giveaway=gift_code.via_giveaway,
|
||||
is_unclaimed=gift_code.unclaimed,
|
||||
boosted_chat=boosted_chat,
|
||||
currency=gift_code.currency,
|
||||
amount=gift_code.amount,
|
||||
crypto_currency=gift_code.crypto_currency,
|
||||
crypto_amount=gift_code.crypto_amount
|
||||
)
|
||||
|
|
@ -486,6 +486,11 @@ class Message(Object, Update):
|
|||
giveaway: "types.Giveaway" = None,
|
||||
giveaway_result: "types.GiveawayResult" = None,
|
||||
boosts_applied: int = None,
|
||||
chat_theme_updated: "types.ChatTheme" = None,
|
||||
chat_wallpaper_updated: "types.ChatWallpaper" = None,
|
||||
contact_registered: "types.ContactRegistered" = None,
|
||||
gift_code: "types.GiftCode" = None,
|
||||
screenshot_taken: "types.ScreenshotTaken" = None,
|
||||
invoice: "types.Invoice" = None,
|
||||
story: Union["types.MessageStory", "types.Story"] = None,
|
||||
video: "types.Video" = None,
|
||||
|
|
@ -599,6 +604,11 @@ class Message(Object, Update):
|
|||
self.giveaway = giveaway
|
||||
self.giveaway_result = giveaway_result
|
||||
self.boosts_applied = boosts_applied
|
||||
self.chat_theme_updated = chat_theme_updated
|
||||
self.chat_wallpaper_updated = chat_wallpaper_updated
|
||||
self.contact_registered = contact_registered
|
||||
self.gift_code = gift_code
|
||||
self.screenshot_taken = screenshot_taken
|
||||
self.invoice = invoice
|
||||
self.story = story
|
||||
self.video = video
|
||||
|
|
@ -756,6 +766,11 @@ class Message(Object, Update):
|
|||
successful_payment = None
|
||||
payment_refunded = None
|
||||
boosts_applied = None
|
||||
chat_theme_updated = None
|
||||
chat_wallpaper_updated = None
|
||||
contact_registered = None
|
||||
gift_code = None
|
||||
screenshot_taken = None
|
||||
|
||||
service_type = None
|
||||
chat_join_type = None
|
||||
|
|
@ -859,6 +874,21 @@ class Message(Object, Update):
|
|||
elif isinstance(action, raw.types.MessageActionPaymentRefunded):
|
||||
payment_refunded = await types.PaymentRefunded._parse(client, action)
|
||||
service_type = enums.MessageServiceType.PAYMENT_REFUNDED
|
||||
elif isinstance(action, raw.types.MessageActionSetChatTheme):
|
||||
chat_theme_updated = types.ChatTheme._parse(action)
|
||||
service_type = enums.MessageServiceType.CHAT_THEME_UPDATED
|
||||
elif isinstance(action, raw.types.MessageActionSetChatWallPaper):
|
||||
chat_wallpaper_updated = types.ChatWallpaper._parse(client, action)
|
||||
service_type = enums.MessageServiceType.CHAT_WALLPAPER_UPDATED
|
||||
elif isinstance(action, raw.types.MessageActionContactSignUp):
|
||||
contact_registered = types.ContactRegistered()
|
||||
service_type = enums.MessageServiceType.CONTACT_REGISTERED
|
||||
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.MessageActionScreenshotTaken):
|
||||
screenshot_taken = types.ScreenshotTaken()
|
||||
service_type = enums.MessageServiceType.SCREENSHOT_TAKEN
|
||||
|
||||
parsed_message = Message(
|
||||
id=message.id,
|
||||
|
|
@ -898,6 +928,11 @@ class Message(Object, Update):
|
|||
successful_payment=successful_payment,
|
||||
payment_refunded=payment_refunded,
|
||||
boosts_applied=boosts_applied,
|
||||
chat_theme_updated=chat_theme_updated,
|
||||
chat_wallpaper_updated=chat_wallpaper_updated,
|
||||
contact_registered=contact_registered,
|
||||
gift_code=gift_code,
|
||||
screenshot_taken=screenshot_taken,
|
||||
raw=message,
|
||||
chat_join_type=chat_join_type,
|
||||
client=client
|
||||
|
|
|
|||
29
pyrogram/types/messages_and_media/screenshot_taken.py
Normal file
29
pyrogram/types/messages_and_media/screenshot_taken.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# 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 ScreenshotTaken(Object):
|
||||
"""A service message about a screenshot taken.
|
||||
|
||||
Currently holds no information.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
93
pyrogram/types/messages_and_media/wallpaper.py
Normal file
93
pyrogram/types/messages_and_media/wallpaper.py
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
# 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/>.
|
||||
|
||||
import pyrogram
|
||||
|
||||
from ..object import Object
|
||||
from pyrogram import raw, types
|
||||
|
||||
class Wallpaper(Object):
|
||||
"""A wallpaper.
|
||||
|
||||
parameters:
|
||||
id (``int``):
|
||||
Unique identifier for this wallpaper.
|
||||
|
||||
slug (``str``):
|
||||
The slug of the wallpaper.
|
||||
|
||||
document (:obj:`~pyrogram.types.Document`):
|
||||
The document of the wallpaper.
|
||||
|
||||
is_creator (:obj:`bool`, optional):
|
||||
True, if the wallpaper was created by the current user.
|
||||
|
||||
is_default (:obj:`bool`, optional):
|
||||
True, if the wallpaper is the default wallpaper.
|
||||
|
||||
is_pattern (:obj:`bool`, optional):
|
||||
True, if the wallpaper is a pattern.
|
||||
|
||||
id_dark (:obj:`bool`, optional):
|
||||
True, if the wallpaper is dark.
|
||||
|
||||
settings (:obj:`~pyrogram.types.WallpaperSettings`, optional):
|
||||
The settings of the wallpaper.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
id: int,
|
||||
slug: str,
|
||||
document: "types.Document",
|
||||
is_creator: bool = None,
|
||||
is_default: bool = None,
|
||||
is_pattern: bool = None,
|
||||
is_dark: bool = None,
|
||||
settings: "types.WallpaperSettings" = None
|
||||
):
|
||||
super().__init__()
|
||||
self.id = id
|
||||
self.slug = slug
|
||||
self.document = document
|
||||
self.is_creator = is_creator
|
||||
self.is_default = is_default
|
||||
self.is_pattern = is_pattern
|
||||
self.is_dark = is_dark
|
||||
self.settings = settings
|
||||
|
||||
@staticmethod
|
||||
def _parse(client: "pyrogram.Client", wallpaper: "raw.base.WallPaper") -> "Wallpaper":
|
||||
doc = wallpaper.document
|
||||
attributes = {type(i): i for i in doc.attributes}
|
||||
|
||||
file_name = getattr(
|
||||
attributes.get(
|
||||
raw.types.DocumentAttributeFilename, None
|
||||
), "file_name", None
|
||||
)
|
||||
return Wallpaper(
|
||||
id=wallpaper.id,
|
||||
slug=wallpaper.slug,
|
||||
document=types.Document._parse(client, doc, file_name),
|
||||
is_creator=getattr(wallpaper, "creator", None),
|
||||
is_default=getattr(wallpaper, "default", None),
|
||||
is_pattern=getattr(wallpaper, "pattern", None),
|
||||
is_dark=getattr(wallpaper, "dark", None),
|
||||
settings=types.WallpaperSettings._parse(wallpaper.settings)
|
||||
)
|
||||
92
pyrogram/types/messages_and_media/wallpaper_settings.py
Normal file
92
pyrogram/types/messages_and_media/wallpaper_settings.py
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
# 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
|
||||
from pyrogram import raw
|
||||
|
||||
class WallpaperSettings(Object):
|
||||
"""A wallpaper settings.
|
||||
|
||||
parameters:
|
||||
is_blur (``bool``, *optional*):
|
||||
True, if the wallpaper is blurred.
|
||||
|
||||
is_motion (``bool``, *optional*):
|
||||
True, if the wallpaper is motion.
|
||||
|
||||
background_color (``int``, *optional*):
|
||||
The background color of the wallpaper.
|
||||
|
||||
second_background_color (``int``, *optional*):
|
||||
The second background color of the wallpaper.
|
||||
|
||||
third_background_color (``int``, *optional*):
|
||||
The third background color of the wallpaper.
|
||||
|
||||
fourth_background_color (``int``, *optional*):
|
||||
The fourth background color of the wallpaper.
|
||||
|
||||
intensity (``int``, *optional*):
|
||||
The intensity of the wallpaper.
|
||||
|
||||
rotation (``int``, *optional*):
|
||||
The rotation of the wallpaper.
|
||||
|
||||
emoticon (``str``, *optional*):
|
||||
The emoticon of the wallpaper.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
is_blur: bool = None,
|
||||
is_motion: bool = None,
|
||||
background_color: int = None,
|
||||
second_background_color: int = None,
|
||||
third_background_color: int = None,
|
||||
fourth_background_color: int = None,
|
||||
intensity: int = None,
|
||||
rotation: int = None,
|
||||
emoticon: str = None
|
||||
):
|
||||
super().__init__()
|
||||
self.is_blur = is_blur
|
||||
self.is_motion = is_motion
|
||||
self.background_color = background_color
|
||||
self.second_background_color = second_background_color
|
||||
self.third_background_color = third_background_color
|
||||
self.fourth_background_color = fourth_background_color
|
||||
self.intensity = intensity
|
||||
self.rotation = rotation
|
||||
self.emoticon = emoticon
|
||||
|
||||
@staticmethod
|
||||
def _parse(wallpaper_settings: "raw.types.WallPaperSettings") -> "WallpaperSettings":
|
||||
if wallpaper_settings is None:
|
||||
return None
|
||||
|
||||
return WallpaperSettings(
|
||||
is_blur=getattr(wallpaper_settings, "blur", None),
|
||||
is_motion=getattr(wallpaper_settings, "motion", None),
|
||||
background_color=getattr(wallpaper_settings, "background_color", None),
|
||||
second_background_color=getattr(wallpaper_settings, "second_background_color", None),
|
||||
third_background_color=getattr(wallpaper_settings, "third_background_color", None),
|
||||
fourth_background_color=getattr(wallpaper_settings, "fourth_background_color", None),
|
||||
intensity=getattr(wallpaper_settings, "intensity", None),
|
||||
rotation=getattr(wallpaper_settings, "rotation", None),
|
||||
emoticon=getattr(wallpaper_settings, "emoticon", None)
|
||||
)
|
||||
Loading…
Reference in a new issue