mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-08 16:04:51 +00:00
Merge remote-tracking branch 'origin/master' into staging
This commit is contained in:
commit
2ef278805b
15 changed files with 502 additions and 6 deletions
|
|
@ -193,7 +193,7 @@ messageActionSetChatTheme#aa786345 emoticon:string = MessageAction;
|
||||||
messageActionChatJoinedByRequest#ebbca3cb = MessageAction;
|
messageActionChatJoinedByRequest#ebbca3cb = MessageAction;
|
||||||
messageActionWebViewDataSentMe#47dd8079 text:string data:string = MessageAction;
|
messageActionWebViewDataSentMe#47dd8079 text:string data:string = MessageAction;
|
||||||
messageActionWebViewDataSent#b4c38cb5 text:string = MessageAction;
|
messageActionWebViewDataSent#b4c38cb5 text:string = MessageAction;
|
||||||
messageActionGiftPremium#aba0f5c6 currency:string amount:long months:int = MessageAction;
|
messageActionGiftPremium#c83d6aec flags:# currency:string amount:long months:int cryptoCurrency:flags.0?string cryptoAmount:flags.0?long = MessageAction;
|
||||||
messageActionTopicCreate#d999256 flags:# title:string icon_color:int icon_emoji_id:flags.0?long = MessageAction;
|
messageActionTopicCreate#d999256 flags:# title:string icon_color:int icon_emoji_id:flags.0?long = MessageAction;
|
||||||
messageActionTopicEdit#c0944820 flags:# title:flags.0?string icon_emoji_id:flags.1?long closed:flags.2?Bool hidden:flags.3?Bool = MessageAction;
|
messageActionTopicEdit#c0944820 flags:# title:flags.0?string icon_emoji_id:flags.1?long closed:flags.2?Bool hidden:flags.3?Bool = MessageAction;
|
||||||
messageActionSuggestProfilePhoto#57de635e photo:Photo = MessageAction;
|
messageActionSuggestProfilePhoto#57de635e photo:Photo = MessageAction;
|
||||||
|
|
@ -739,7 +739,7 @@ auth.sentCodeTypeSms#c000bba2 length:int = auth.SentCodeType;
|
||||||
auth.sentCodeTypeCall#5353e5a7 length:int = auth.SentCodeType;
|
auth.sentCodeTypeCall#5353e5a7 length:int = auth.SentCodeType;
|
||||||
auth.sentCodeTypeFlashCall#ab03c6d9 pattern:string = auth.SentCodeType;
|
auth.sentCodeTypeFlashCall#ab03c6d9 pattern:string = auth.SentCodeType;
|
||||||
auth.sentCodeTypeMissedCall#82006484 prefix:string length:int = auth.SentCodeType;
|
auth.sentCodeTypeMissedCall#82006484 prefix:string length:int = auth.SentCodeType;
|
||||||
auth.sentCodeTypeEmailCode#5a159841 flags:# apple_signin_allowed:flags.0?true google_signin_allowed:flags.1?true email_pattern:string length:int next_phone_login_date:flags.2?int = auth.SentCodeType;
|
auth.sentCodeTypeEmailCode#f450f59b flags:# apple_signin_allowed:flags.0?true google_signin_allowed:flags.1?true email_pattern:string length:int reset_available_period:flags.3?int reset_pending_date:flags.4?int = auth.SentCodeType;
|
||||||
auth.sentCodeTypeSetUpEmailRequired#a5491dea flags:# apple_signin_allowed:flags.0?true google_signin_allowed:flags.1?true = auth.SentCodeType;
|
auth.sentCodeTypeSetUpEmailRequired#a5491dea flags:# apple_signin_allowed:flags.0?true google_signin_allowed:flags.1?true = auth.SentCodeType;
|
||||||
auth.sentCodeTypeFragmentSms#d9565c39 url:string length:int = auth.SentCodeType;
|
auth.sentCodeTypeFragmentSms#d9565c39 url:string length:int = auth.SentCodeType;
|
||||||
auth.sentCodeTypeFirebaseSms#e57b1432 flags:# nonce:flags.0?bytes receipt:flags.1?string push_timeout:flags.1?int length:int = auth.SentCodeType;
|
auth.sentCodeTypeFirebaseSms#e57b1432 flags:# nonce:flags.0?bytes receipt:flags.1?string push_timeout:flags.1?int length:int = auth.SentCodeType;
|
||||||
|
|
@ -1557,6 +1557,7 @@ auth.acceptLoginToken#e894ad4d token:bytes = Authorization;
|
||||||
auth.checkRecoveryPassword#d36bf79 code:string = Bool;
|
auth.checkRecoveryPassword#d36bf79 code:string = Bool;
|
||||||
auth.importWebTokenAuthorization#2db873a9 api_id:int api_hash:string web_auth_token:string = auth.Authorization;
|
auth.importWebTokenAuthorization#2db873a9 api_id:int api_hash:string web_auth_token:string = auth.Authorization;
|
||||||
auth.requestFirebaseSms#89464b50 flags:# phone_number:string phone_code_hash:string safety_net_token:flags.0?string ios_push_secret:flags.1?string = Bool;
|
auth.requestFirebaseSms#89464b50 flags:# phone_number:string phone_code_hash:string safety_net_token:flags.0?string ios_push_secret:flags.1?string = Bool;
|
||||||
|
auth.resetLoginEmail#7e960193 phone_number:string phone_code_hash:string = auth.SentCode;
|
||||||
|
|
||||||
account.registerDevice#ec86017a flags:# no_muted:flags.0?true token_type:int token:string app_sandbox:Bool secret:bytes other_uids:Vector<long> = Bool;
|
account.registerDevice#ec86017a flags:# no_muted:flags.0?true token_type:int token:string app_sandbox:Bool secret:bytes other_uids:Vector<long> = Bool;
|
||||||
account.unregisterDevice#6a0d3206 token_type:int token:string other_uids:Vector<long> = Bool;
|
account.unregisterDevice#6a0d3206 token_type:int token:string other_uids:Vector<long> = Bool;
|
||||||
|
|
@ -2043,4 +2044,4 @@ stats.getMegagroupStats#dcdf8607 flags:# dark:flags.0?true channel:InputChannel
|
||||||
stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;
|
stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;
|
||||||
stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats;
|
stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats;
|
||||||
|
|
||||||
// LAYER 155
|
// LAYER 157
|
||||||
|
|
|
||||||
|
|
@ -256,6 +256,12 @@ def pyrogram_api():
|
||||||
get_default_emoji_statuses
|
get_default_emoji_statuses
|
||||||
set_emoji_status
|
set_emoji_status
|
||||||
""",
|
""",
|
||||||
|
stickers="""
|
||||||
|
Stickers
|
||||||
|
add_sticker_to_set
|
||||||
|
create_sticker_set
|
||||||
|
get_sticker_set
|
||||||
|
""",
|
||||||
invite_links="""
|
invite_links="""
|
||||||
Invite Links
|
Invite Links
|
||||||
get_chat_invite_link
|
get_chat_invite_link
|
||||||
|
|
@ -411,6 +417,7 @@ def pyrogram_api():
|
||||||
Location
|
Location
|
||||||
Venue
|
Venue
|
||||||
Sticker
|
Sticker
|
||||||
|
StickerSet
|
||||||
Game
|
Game
|
||||||
WebPage
|
WebPage
|
||||||
Poll
|
Poll
|
||||||
|
|
|
||||||
13
compiler/docs/template/methods.rst
vendored
13
compiler/docs/template/methods.rst
vendored
|
|
@ -73,6 +73,19 @@ Chats
|
||||||
|
|
||||||
{chats}
|
{chats}
|
||||||
|
|
||||||
|
Stickers
|
||||||
|
-----
|
||||||
|
|
||||||
|
.. autosummary::
|
||||||
|
:nosignatures:
|
||||||
|
|
||||||
|
{stickers}
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:hidden:
|
||||||
|
|
||||||
|
{stickers}
|
||||||
|
|
||||||
Users
|
Users
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
__fork_name__ = "PyroFork"
|
__fork_name__ = "PyroFork"
|
||||||
__version__ = "2.1.4"
|
__version__ = "2.1.5"
|
||||||
__license__ = "GNU Lesser General Public License v3.0 (LGPL-3.0)"
|
__license__ = "GNU Lesser General Public License v3.0 (LGPL-3.0)"
|
||||||
__copyright__ = "Copyright (C) 2017-present Dan <https://github.com/delivrance>"
|
__copyright__ = "Copyright (C) 2017-present Dan <https://github.com/delivrance>"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ from .decorators import Decorators
|
||||||
from .invite_links import InviteLinks
|
from .invite_links import InviteLinks
|
||||||
from .messages import Messages
|
from .messages import Messages
|
||||||
from .password import Password
|
from .password import Password
|
||||||
|
from .stickers import Stickers
|
||||||
from .users import Users
|
from .users import Users
|
||||||
from .utilities import Utilities
|
from .utilities import Utilities
|
||||||
|
|
||||||
|
|
@ -36,6 +37,7 @@ class Methods(
|
||||||
Contacts,
|
Contacts,
|
||||||
Password,
|
Password,
|
||||||
Chats,
|
Chats,
|
||||||
|
Stickers,
|
||||||
Users,
|
Users,
|
||||||
Messages,
|
Messages,
|
||||||
Decorators,
|
Decorators,
|
||||||
|
|
|
||||||
28
pyrogram/methods/stickers/__init__.py
Normal file
28
pyrogram/methods/stickers/__init__.py
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrogram.
|
||||||
|
#
|
||||||
|
# Pyrogram 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.
|
||||||
|
#
|
||||||
|
# Pyrogram 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 Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from .add_sticker_to_set import AddStickerToSet
|
||||||
|
from .create_sticker_set import CreateStickerSet
|
||||||
|
from .get_sticker_set import GetStickerSet
|
||||||
|
|
||||||
|
class Stickers(
|
||||||
|
AddStickerToSet,
|
||||||
|
CreateStickerSet,
|
||||||
|
GetStickerSet
|
||||||
|
):
|
||||||
|
pass
|
||||||
85
pyrogram/methods/stickers/add_sticker_to_set.py
Normal file
85
pyrogram/methods/stickers/add_sticker_to_set.py
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrogram.
|
||||||
|
#
|
||||||
|
# Pyrogram 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.
|
||||||
|
#
|
||||||
|
# Pyrogram 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 Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram import raw
|
||||||
|
from pyrogram import types
|
||||||
|
|
||||||
|
class AddStickerToSet:
|
||||||
|
async def add_sticker_to_set(
|
||||||
|
self: "pyrogram.Client",
|
||||||
|
set_short_name: str,
|
||||||
|
sticker: str,
|
||||||
|
emoji: str = "🤔",
|
||||||
|
) -> "types.StickerSet":
|
||||||
|
"""Add a sticker to stickerset.
|
||||||
|
|
||||||
|
.. include:: /_includes/usable-by/bots.rst
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
set_short_name (``str``):
|
||||||
|
Stickerset shortname.
|
||||||
|
|
||||||
|
sticker (``str``):
|
||||||
|
sticker to add.
|
||||||
|
Pass a file_id as string to send a file that exists on the Telegram servers.
|
||||||
|
|
||||||
|
emoji (``str``, *optional*):
|
||||||
|
Associated emoji.
|
||||||
|
default to "🤔"
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
:obj:`~pyrogram.types.StickerSet`: On success, the StickerSet information is returned.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
await app.add_sticker_to_set("mypack1", "AsJiasp")
|
||||||
|
"""
|
||||||
|
file = None
|
||||||
|
|
||||||
|
if isinstance(sticker, str):
|
||||||
|
if os.path.isfile(sticker) or re.match("^https?://", sticker):
|
||||||
|
raise ValueError(f"file_id is invalid!")
|
||||||
|
else:
|
||||||
|
decoded = FileId.decode(sticker)
|
||||||
|
media = raw.types.InputDocument(
|
||||||
|
id=decoded.media_id,
|
||||||
|
access_hash=decoded.access_hash,
|
||||||
|
file_reference=decoded.file_reference
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
raise ValueError(f"file_id is invalid!")
|
||||||
|
|
||||||
|
r = await self.invoke(
|
||||||
|
raw.functions.stickers.AddStickerToSet(
|
||||||
|
stickerset=raw.types.InputStickerSetShortName(short_name=set_short_name),
|
||||||
|
sticker=[
|
||||||
|
raw.types.InputStickerSetItem(
|
||||||
|
document=media,
|
||||||
|
emoji=emoji
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return types.StickerSet._parse(r.set)
|
||||||
122
pyrogram/methods/stickers/create_sticker_set.py
Normal file
122
pyrogram/methods/stickers/create_sticker_set.py
Normal file
|
|
@ -0,0 +1,122 @@
|
||||||
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrogram.
|
||||||
|
#
|
||||||
|
# Pyrogram 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.
|
||||||
|
#
|
||||||
|
# Pyrogram 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 Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
from typing import Union, Optional
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram import raw
|
||||||
|
from pyrogram import types
|
||||||
|
from pyrogram.file_id import FileId
|
||||||
|
|
||||||
|
|
||||||
|
class CreateStickerSet:
|
||||||
|
async def create_sticker_set(
|
||||||
|
self: "pyrogram.Client",
|
||||||
|
user_id: Union[int, str],
|
||||||
|
title: str,
|
||||||
|
short_name: str,
|
||||||
|
sticker: str,
|
||||||
|
emoji: str = "🤔",
|
||||||
|
masks: bool = None,
|
||||||
|
animated: bool = None,
|
||||||
|
videos: bool = None,
|
||||||
|
emojis: bool = None
|
||||||
|
) -> Optional["types.Message"]:
|
||||||
|
"""Create a new stickerset.
|
||||||
|
|
||||||
|
.. include:: /_includes/usable-by/users-bots.rst
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
user_id (``int`` | ``str``):
|
||||||
|
Unique identifier (int) or username (str) of the Stickerset owner.
|
||||||
|
For you yourself you can simply use "me" or "self" (users only).
|
||||||
|
|
||||||
|
title (``str``):
|
||||||
|
Stickerset name, 1-64 chars
|
||||||
|
|
||||||
|
short_name (``str``, *optional*):
|
||||||
|
Short name of sticker set, to be used in sticker deep links.
|
||||||
|
Can contain only english letters, digits and underscores.
|
||||||
|
Must begin with a letter, can't contain consecutive underscores and, if called by a bot, must end in "_by_<bot_username>".
|
||||||
|
<bot_username> is case insensitive. 1-64 characters.
|
||||||
|
|
||||||
|
sticker (``str``):
|
||||||
|
sticker to add.
|
||||||
|
Pass a file_id as string to send a file that exists on the Telegram servers.
|
||||||
|
|
||||||
|
emoji (``str``, *optional*):
|
||||||
|
Associated emoji.
|
||||||
|
default to "🤔"
|
||||||
|
|
||||||
|
masks (``bool``, *optional*):
|
||||||
|
Whether this is a mask stickerset.
|
||||||
|
|
||||||
|
animated (``bool``, *optional*):
|
||||||
|
Whether this is a animated stickerset.
|
||||||
|
|
||||||
|
videos (``bool``, *optional*):
|
||||||
|
Whether this is a videos stickerset.
|
||||||
|
|
||||||
|
emojis (``bool``, *optional*):
|
||||||
|
Whether this is a emojis stickerset.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
:obj:`~pyrogram.types.StickerSet` | ``None``: On success, the StickerSet is returned.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
# Send document by uploading from local file
|
||||||
|
await app.create_sticker_set("me", "My First Pack", "myfirstpack", "AAjjHjk")
|
||||||
|
"""
|
||||||
|
file = None
|
||||||
|
|
||||||
|
if isinstance(sticker, str):
|
||||||
|
if os.path.isfile(sticker) or re.match("^https?://", sticker):
|
||||||
|
raise ValueError(f"file_id is invalid!")
|
||||||
|
else:
|
||||||
|
decoded = FileId.decode(sticker)
|
||||||
|
media = raw.types.InputDocument(
|
||||||
|
id=decoded.media_id,
|
||||||
|
access_hash=decoded.access_hash,
|
||||||
|
file_reference=decoded.file_reference
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
raise ValueError(f"file_id is invalid!")
|
||||||
|
|
||||||
|
r = await self.invoke(
|
||||||
|
raw.functions.stickers.CreateStickerSet(
|
||||||
|
user_id=await self.resolve_peer(user_id),
|
||||||
|
title=title,
|
||||||
|
short_name=short_name,
|
||||||
|
stickers=[
|
||||||
|
raw.types.InputStickerSetItem(
|
||||||
|
document=media,
|
||||||
|
emoji=emoji
|
||||||
|
)
|
||||||
|
],
|
||||||
|
masks=masks,
|
||||||
|
animated=animated,
|
||||||
|
videos=videos,
|
||||||
|
emojis=emojis
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return types.StickerSet._parse(r.set)
|
||||||
54
pyrogram/methods/stickers/get_sticker_set.py
Normal file
54
pyrogram/methods/stickers/get_sticker_set.py
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrogram.
|
||||||
|
#
|
||||||
|
# Pyrogram 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.
|
||||||
|
#
|
||||||
|
# Pyrogram 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 Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram import raw
|
||||||
|
from pyrogram import types
|
||||||
|
|
||||||
|
|
||||||
|
class GetStickerSet:
|
||||||
|
async def get_sticker_set(
|
||||||
|
self: "pyrogram.Client",
|
||||||
|
set_short_name: str
|
||||||
|
) -> "types.StickerSet":
|
||||||
|
"""Get info about a stickerset.
|
||||||
|
|
||||||
|
.. include:: /_includes/usable-by/users-bots.rst
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
set_short_name (``str``):
|
||||||
|
Stickerset shortname.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
:obj:`~pyrogram.types.StickerSet`: On success, the StickerSet information is returned.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
await app.get_sticker_set("mypack1")
|
||||||
|
"""
|
||||||
|
r = await self.invoke(
|
||||||
|
raw.functions.messages.GetStickerSet(
|
||||||
|
stickerset=raw.types.InputStickerSetShortName(short_name=set_short_name),
|
||||||
|
hash=0
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return types.StickerSet._parse(r.set)
|
||||||
|
|
@ -30,6 +30,7 @@ from .poll import Poll
|
||||||
from .poll_option import PollOption
|
from .poll_option import PollOption
|
||||||
from .reaction import Reaction
|
from .reaction import Reaction
|
||||||
from .sticker import Sticker
|
from .sticker import Sticker
|
||||||
|
from .stickerset import StickerSet
|
||||||
from .stripped_thumbnail import StrippedThumbnail
|
from .stripped_thumbnail import StrippedThumbnail
|
||||||
from .thumbnail import Thumbnail
|
from .thumbnail import Thumbnail
|
||||||
from .venue import Venue
|
from .venue import Venue
|
||||||
|
|
@ -42,6 +43,6 @@ from .message_reactions import MessageReactions
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Photo", "Thumbnail",
|
"Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Photo", "Thumbnail",
|
||||||
"StrippedThumbnail", "Poll", "PollOption", "Sticker", "Venue", "Video", "VideoNote", "Voice", "WebPage", "Dice",
|
"StrippedThumbnail", "Poll", "PollOption", "Sticker", "StickerSet", "Venue", "Video", "VideoNote", "Voice", "WebPage", "Dice",
|
||||||
"Reaction", "WebAppData", "MessageReactions"
|
"Reaction", "WebAppData", "MessageReactions"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
89
pyrogram/types/messages_and_media/stickerset.py
Normal file
89
pyrogram/types/messages_and_media/stickerset.py
Normal file
|
|
@ -0,0 +1,89 @@
|
||||||
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrogram.
|
||||||
|
#
|
||||||
|
# Pyrogram 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.
|
||||||
|
#
|
||||||
|
# Pyrogram 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 Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import List, Optional, Union
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram import raw
|
||||||
|
from pyrogram.file_id import FileId, FileType, FileUniqueId, FileUniqueType, ThumbnailSource
|
||||||
|
from ..object import Object
|
||||||
|
|
||||||
|
|
||||||
|
class StickerSet(Object):
|
||||||
|
"""A stickerset.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
id (``Integer``):
|
||||||
|
Identifier for this stickerset.
|
||||||
|
|
||||||
|
title (``String``):
|
||||||
|
Title of stickerset.
|
||||||
|
|
||||||
|
short_name (``String``):
|
||||||
|
Short name of stickerset, used when sharing stickerset using stickerset deep links.
|
||||||
|
|
||||||
|
count (``Integer``):
|
||||||
|
Number of stickers in stickerset.
|
||||||
|
|
||||||
|
masks (``Boolean``):
|
||||||
|
Is this a mask stickerset.
|
||||||
|
|
||||||
|
animated (``Boolean``):
|
||||||
|
Is this a animated stickerset.
|
||||||
|
|
||||||
|
videos (``Boolean``):
|
||||||
|
Is this a videos stickerset.
|
||||||
|
|
||||||
|
emojis (``Boolean``):
|
||||||
|
Is this a emojis stickerset.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
id: int,
|
||||||
|
title: str,
|
||||||
|
short_name: str,
|
||||||
|
count: int,
|
||||||
|
masks: bool = None,
|
||||||
|
animated: bool = None,
|
||||||
|
videos: bool = None,
|
||||||
|
emojis: bool = None
|
||||||
|
):
|
||||||
|
self.id = id
|
||||||
|
self.title = title
|
||||||
|
self.short_name = short_name
|
||||||
|
self.count = count
|
||||||
|
self.masks = masks
|
||||||
|
self.animated = animated
|
||||||
|
self.videos = videos
|
||||||
|
self.emojis = emojis
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _parse(stickerset: "raw.types.StickerSet") -> "StickerSet":
|
||||||
|
|
||||||
|
return StickerSet(
|
||||||
|
id=getattr(stickerset,"id", None),
|
||||||
|
title=getattr(stickerset,"title", None),
|
||||||
|
short_name=getattr(stickerset,"short_name", None),
|
||||||
|
count=getattr(stickerset,"count", None),
|
||||||
|
masks=getattr(stickerset,"masks", None),
|
||||||
|
animated=getattr(stickerset,"animated", None),
|
||||||
|
videos=getattr(stickerset,"videos", None),
|
||||||
|
emojis=getattr(stickerset,"emojis", None)
|
||||||
|
)
|
||||||
|
|
@ -36,6 +36,7 @@ from .emoji_status import EmojiStatus
|
||||||
from .invite_link_importer import InviteLinkImporter
|
from .invite_link_importer import InviteLinkImporter
|
||||||
from .restriction import Restriction
|
from .restriction import Restriction
|
||||||
from .user import User
|
from .user import User
|
||||||
|
from .username import Username
|
||||||
from .forum_topic import ForumTopic
|
from .forum_topic import ForumTopic
|
||||||
from .forum_topic_created import ForumTopicCreated
|
from .forum_topic_created import ForumTopicCreated
|
||||||
from .forum_topic_closed import ForumTopicClosed
|
from .forum_topic_closed import ForumTopicClosed
|
||||||
|
|
@ -58,6 +59,7 @@ __all__ = [
|
||||||
"ChatPreview",
|
"ChatPreview",
|
||||||
"Dialog",
|
"Dialog",
|
||||||
"User",
|
"User",
|
||||||
|
"Username",
|
||||||
"Restriction",
|
"Restriction",
|
||||||
"ChatEvent",
|
"ChatEvent",
|
||||||
"ChatEventFilter",
|
"ChatEventFilter",
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,13 @@ class Chat(Object):
|
||||||
available_reactions (:obj:`~pyrogram.types.ChatReactions`, *optional*):
|
available_reactions (:obj:`~pyrogram.types.ChatReactions`, *optional*):
|
||||||
Available reactions in the chat.
|
Available reactions in the chat.
|
||||||
Returned only in :meth:`~pyrogram.Client.get_chat`.
|
Returned only in :meth:`~pyrogram.Client.get_chat`.
|
||||||
|
|
||||||
|
full_name (``str``, *property*):
|
||||||
|
Full name of the other party in a private chat, for private chats and bots.
|
||||||
|
|
||||||
|
usernames (List of :obj:`~pyrogram.types.Username`, *optional*):
|
||||||
|
List of all chat (fragment) usernames; for private chats, supergroups and channels.
|
||||||
|
Returned only in :meth:`~pyrogram.Client.get_chat`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
@ -166,7 +173,8 @@ class Chat(Object):
|
||||||
distance: int = None,
|
distance: int = None,
|
||||||
linked_chat: "types.Chat" = None,
|
linked_chat: "types.Chat" = None,
|
||||||
send_as_chat: "types.Chat" = None,
|
send_as_chat: "types.Chat" = None,
|
||||||
available_reactions: Optional["types.ChatReactions"] = None
|
available_reactions: Optional["types.ChatReactions"] = None,
|
||||||
|
usernames: List["types.Username"] = None
|
||||||
):
|
):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
|
|
@ -199,6 +207,11 @@ class Chat(Object):
|
||||||
self.linked_chat = linked_chat
|
self.linked_chat = linked_chat
|
||||||
self.send_as_chat = send_as_chat
|
self.send_as_chat = send_as_chat
|
||||||
self.available_reactions = available_reactions
|
self.available_reactions = available_reactions
|
||||||
|
self.usernames = usernames
|
||||||
|
|
||||||
|
@property
|
||||||
|
def full_name(self) -> str:
|
||||||
|
return " ".join(filter(None, [self.first_name, self.last_name])) or None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_user_chat(client, user: raw.types.User) -> "Chat":
|
def _parse_user_chat(client, user: raw.types.User) -> "Chat":
|
||||||
|
|
@ -224,6 +237,12 @@ class Chat(Object):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_chat_chat(client, chat: raw.types.Chat) -> "Chat":
|
def _parse_chat_chat(client, chat: raw.types.Chat) -> "Chat":
|
||||||
peer_id = -chat.id
|
peer_id = -chat.id
|
||||||
|
active_usernames = getattr(chat, "usernames", [])
|
||||||
|
usernames = None
|
||||||
|
if len(active_usernames) >= 1:
|
||||||
|
usernames = []
|
||||||
|
for username in active_usernames:
|
||||||
|
usernames.append(types.Username._parse(username))
|
||||||
|
|
||||||
return Chat(
|
return Chat(
|
||||||
id=peer_id,
|
id=peer_id,
|
||||||
|
|
@ -235,6 +254,7 @@ class Chat(Object):
|
||||||
members_count=getattr(chat, "participants_count", None),
|
members_count=getattr(chat, "participants_count", None),
|
||||||
dc_id=getattr(getattr(chat, "photo", None), "dc_id", None),
|
dc_id=getattr(getattr(chat, "photo", None), "dc_id", None),
|
||||||
has_protected_content=getattr(chat, "noforwards", None),
|
has_protected_content=getattr(chat, "noforwards", None),
|
||||||
|
usernames=usernames,
|
||||||
client=client
|
client=client
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -242,6 +262,12 @@ class Chat(Object):
|
||||||
def _parse_channel_chat(client, channel: raw.types.Channel) -> "Chat":
|
def _parse_channel_chat(client, channel: raw.types.Channel) -> "Chat":
|
||||||
peer_id = utils.get_channel_id(channel.id)
|
peer_id = utils.get_channel_id(channel.id)
|
||||||
restriction_reason = getattr(channel, "restriction_reason", [])
|
restriction_reason = getattr(channel, "restriction_reason", [])
|
||||||
|
active_usernames = getattr(channel, "usernames", [])
|
||||||
|
usernames = None
|
||||||
|
if len(active_usernames) >= 1:
|
||||||
|
usernames = []
|
||||||
|
for username in active_usernames:
|
||||||
|
usernames.append(types.Username._parse(username))
|
||||||
|
|
||||||
return Chat(
|
return Chat(
|
||||||
id=peer_id,
|
id=peer_id,
|
||||||
|
|
@ -254,6 +280,7 @@ class Chat(Object):
|
||||||
is_forum=getattr(channel, "forum", None),
|
is_forum=getattr(channel, "forum", None),
|
||||||
title=channel.title,
|
title=channel.title,
|
||||||
username=getattr(channel, "username", None),
|
username=getattr(channel, "username", None),
|
||||||
|
usernames=usernames,
|
||||||
photo=types.ChatPhoto._parse(client, getattr(channel, "photo", None), peer_id,
|
photo=types.ChatPhoto._parse(client, getattr(channel, "photo", None), peer_id,
|
||||||
getattr(channel, "access_hash", 0)),
|
getattr(channel, "access_hash", 0)),
|
||||||
restrictions=types.List([types.Restriction._parse(r) for r in restriction_reason]) or None,
|
restrictions=types.List([types.Restriction._parse(r) for r in restriction_reason]) or None,
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,9 @@ class User(Object, Update):
|
||||||
The list of reasons why this bot might be unavailable to some users.
|
The list of reasons why this bot might be unavailable to some users.
|
||||||
This field is available only in case *is_restricted* is True.
|
This field is available only in case *is_restricted* is True.
|
||||||
|
|
||||||
|
full_name (``str``, *optional*):
|
||||||
|
User's or bot's full name.
|
||||||
|
|
||||||
mention (``str``, *property*):
|
mention (``str``, *property*):
|
||||||
Generate a text mention for this user.
|
Generate a text mention for this user.
|
||||||
You can use ``user.mention()`` to mention the user using their first name (styled using html), or
|
You can use ``user.mention()`` to mention the user using their first name (styled using html), or
|
||||||
|
|
@ -203,6 +206,10 @@ class User(Object, Update):
|
||||||
self.photo = photo
|
self.photo = photo
|
||||||
self.restrictions = restrictions
|
self.restrictions = restrictions
|
||||||
|
|
||||||
|
@property
|
||||||
|
def full_name(self) -> str:
|
||||||
|
return " ".join(filter(None, [self.first_name, self.last_name])) or None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mention(self):
|
def mention(self):
|
||||||
return Link(
|
return Link(
|
||||||
|
|
|
||||||
58
pyrogram/types/user_and_chats/username.py
Normal file
58
pyrogram/types/user_and_chats/username.py
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrogram.
|
||||||
|
#
|
||||||
|
# Pyrogram 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.
|
||||||
|
#
|
||||||
|
# Pyrogram 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 Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from pyrogram import raw
|
||||||
|
from ..object import Object
|
||||||
|
|
||||||
|
|
||||||
|
class Username(Object):
|
||||||
|
"""A Username.
|
||||||
|
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
username (``String``):
|
||||||
|
The channel/user username.
|
||||||
|
|
||||||
|
editable (``bool``, *optional*):
|
||||||
|
Can the username edited.
|
||||||
|
|
||||||
|
active (``bool``, *optional*)
|
||||||
|
Is the username active.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self, *,
|
||||||
|
username: str,
|
||||||
|
editable: bool = None,
|
||||||
|
active: bool = None
|
||||||
|
):
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
self.username = username
|
||||||
|
self.editable = editable
|
||||||
|
self.active = active
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _parse(action: "raw.types.Username") -> "Username":
|
||||||
|
|
||||||
|
|
||||||
|
return Username(
|
||||||
|
username=getattr(action,"username", None),
|
||||||
|
editable=getattr(action,"editable", None),
|
||||||
|
active=getattr(action,"active", None)
|
||||||
|
)
|
||||||
Loading…
Reference in a new issue