Skip to content

Commit 1454579

Browse files
Add missing fields to Sticker class
1 parent c394c4f commit 1454579

7 files changed

Lines changed: 242 additions & 20 deletions

File tree

compiler/docs/compiler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ def get_title_list(s: str) -> list:
665665
VideoNote
666666
Contact
667667
Location
668+
MaskPosition
668669
MediaArea
669670
Venue
670671
Sticker
@@ -1094,6 +1095,8 @@ def get_title_list(s: str) -> list:
10941095
PrivacyRuleType
10951096
GiftForResaleOrder
10961097
PaymentFormType
1098+
StickerType
1099+
MaskPointType
10971100
""",
10981101
)
10991102

pyrogram/enums/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@
4141
from .profile_color import ProfileColor
4242
from .reply_color import ReplyColor
4343
from .sent_code_type import SentCodeType
44+
from .sticker_type import StickerType
4445
from .gift_attribute_type import GiftAttributeType
4546
from .gift_for_resale_order import GiftForResaleOrder
47+
from .mask_point_type import MaskPointType
4648
from .media_area_type import MediaAreaType
4749
from .stories_privacy_rules import StoriesPrivacyRules
4850
from .user_status import UserStatus
@@ -73,8 +75,10 @@
7375
'ProfileColor',
7476
'ReplyColor',
7577
'SentCodeType',
78+
'StickerType',
7679
'GiftAttributeType',
7780
'GiftForResaleOrder',
81+
'MaskPointType',
7882
'MediaAreaType',
7983
'StoriesPrivacyRules',
8084
'UserStatus'

pyrogram/enums/mask_point_type.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
3+
#
4+
# This file is part of Pyrogram.
5+
#
6+
# Pyrogram is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Pyrogram is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+
from .auto_name import AutoName
20+
21+
22+
class MaskPointType(AutoName):
23+
"""Mask point type enumeration used in :obj:`~pyrogram.types.MaskPosition`."""
24+
25+
FOREHEAD = 0
26+
"Mask point relative to the forehead."
27+
28+
EYES = 1
29+
"Mask point relative to the eyes."
30+
31+
MOUTH = 2
32+
"Mask point relative to the mouth."
33+
34+
CHIN = 3
35+
"Mask point relative to the chin."

pyrogram/enums/sticker_type.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
3+
#
4+
# This file is part of Pyrogram.
5+
#
6+
# Pyrogram is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Pyrogram is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+
from enum import auto
20+
21+
from .auto_name import AutoName
22+
23+
24+
class StickerType(AutoName):
25+
"""Sticker type enumeration used in :obj:`~pyrogram.types.Sticker`."""
26+
27+
REGULAR = auto()
28+
"The sticker is a regular sticker"
29+
30+
MASK = auto()
31+
"The sticker is a mask in WEBP format to be placed on photos or videos."
32+
33+
CUSTOM_EMOJI = auto()
34+
"The sticker is a custom emoji to be used inside message text and caption."

pyrogram/types/messages_and_media/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
from .giveaway_prize_stars import GiveawayPrizeStars
5858
from .giveaway_winners import GiveawayWinners
5959
from .location import Location
60+
from .mask_position import MaskPosition
6061
from .media_area import MediaArea
6162
from .message import Message
6263
from .message_entity import MessageEntity
@@ -151,6 +152,7 @@
151152
"GiveawayPrizeStars",
152153
"GiveawayWinners",
153154
"Location",
155+
"MaskPosition",
154156
"MediaArea",
155157
"Message",
156158
"MessageEntity",
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
3+
#
4+
# This file is part of Pyrogram.
5+
#
6+
# Pyrogram is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Pyrogram is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+
20+
from pyrogram import enums, raw
21+
22+
from ..object import Object
23+
24+
25+
class MaskPosition(Object):
26+
"""This object describes the position on faces where a mask should be placed by default.
27+
28+
Parameters:
29+
point (:obj:`~pyrogram.enums.MaskPointType`):
30+
The part of the face relative to which the mask should be placed.
31+
32+
x_shift (``float``):
33+
Shift by X-axis measured in widths of the mask scaled to the face size, from left to right.
34+
For example, choosing -1.0 will place mask just to the left of the default mask position.
35+
36+
y_shift (``float``):
37+
Shift by Y-axis measured in heights of the mask scaled to the face size, from top to bottom.
38+
For example, 1.0 will place the mask just below the default mask position.
39+
40+
scale (``float``):
41+
Mask scaling coefficient. For example, 2.0 means double size.
42+
"""
43+
def __init__(
44+
self,
45+
*,
46+
point: "enums.MaskPointType",
47+
x_shift: float,
48+
y_shift: float,
49+
scale: float
50+
):
51+
super().__init__()
52+
53+
self.point = point
54+
self.x_shift = x_shift
55+
self.y_shift = y_shift
56+
self.scale = scale
57+
58+
@staticmethod
59+
def _parse(
60+
coords: "raw.types.MaskCoords"
61+
) -> "MaskPosition":
62+
if not coords:
63+
return None
64+
65+
return MaskPosition(
66+
point=enums.MaskPointType(coords.n),
67+
x_shift=coords.x,
68+
y_shift=coords.y,
69+
scale=coords.zoom
70+
)

0 commit comments

Comments
 (0)