-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pyrofork: Add some missings service messages
CHAT_THEME_UPDATED CHAT_WALLPAPER_UPDATED CONTACT_REGISTERED GIFT_CODE SCREENSHOT_TAKEN Signed-off-by: wulan17 <[email protected]>
- Loading branch information
Showing
11 changed files
with
551 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# 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): | ||
super().__init__() | ||
|
||
@staticmethod | ||
def _parse(chat_theme: "raw.types.MessageActionSetChatTheme") -> "ChatTheme": | ||
return ChatTheme( | ||
emoticon=getattr(chat_theme, "emoticon", None) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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__() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_channel_id(gift_code.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.is_giveaway, | ||
is_unclaimed=gift_code.is_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 | ||
) |
Oops, something went wrong.