Skip to content

Commit cc04a9e

Browse files
committed
Update Pyrogram to v2.0.40
Update to Pyrogram v2.0.40 from the latest commit on the official repo https://github.com/pyrogram/pyrogram/
1 parent c90dd5f commit cc04a9e

6 files changed

Lines changed: 32 additions & 24 deletions

File tree

pyrogram/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
__version__ = "2.0.38"
19+
__version__ = "2.0.40"
2020
__license__ = "GNU Lesser General Public License v3.0 (LGPL-3.0)"
2121
__copyright__ = "Copyright (C) 2017-present Dan <https://github.com/delivrance>"
2222

pyrogram/methods/messages/get_custom_emoji_stickers.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,7 @@ async def get_custom_emoji_stickers(
4747
stickers = []
4848
for item in result:
4949
attributes = {type(i): i for i in item.attributes}
50-
51-
sticker = await types.Sticker._parse(
52-
self, item,
53-
attributes[raw.types.DocumentAttributeImageSize],
54-
attributes[raw.types.DocumentAttributeCustomEmoji],
55-
attributes[raw.types.DocumentAttributeFilename].file_name
56-
)
57-
50+
sticker = await types.Sticker._parse(self, item, attributes)
5851
stickers.append(sticker)
5952

6053
return pyrogram.types.List(stickers)

pyrogram/session/session.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ async def handle_packet(self, packet):
197197
self.stored_msg_ids
198198
)
199199
except SecurityCheckMismatch:
200-
self.connection.close()
201200
return
202201

203202
messages = (

pyrogram/types/messages_and_media/message.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -698,12 +698,7 @@ async def _parse(
698698
animation = types.Animation._parse(client, doc, video_attributes, file_name)
699699
media_type = enums.MessageMediaType.ANIMATION
700700
elif raw.types.DocumentAttributeSticker in attributes:
701-
sticker = await types.Sticker._parse(
702-
client, doc,
703-
attributes.get(raw.types.DocumentAttributeImageSize, None),
704-
attributes[raw.types.DocumentAttributeSticker],
705-
file_name
706-
)
701+
sticker = await types.Sticker._parse(client, doc, attributes)
707702
media_type = enums.MessageMediaType.STICKER
708703
elif raw.types.DocumentAttributeVideo in attributes:
709704
video_attributes = attributes[raw.types.DocumentAttributeVideo]

pyrogram/types/messages_and_media/message_entity.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ async def write(self):
112112
if self.language is None:
113113
args.pop("language")
114114

115-
if self.custom_emoji_id is None:
116-
args.pop("custom_emoji_id")
115+
args.pop("custom_emoji_id")
116+
if self.custom_emoji_id is not None:
117+
args["document_id"] = self.custom_emoji_id
117118

118119
entity = self.type.value
119120

pyrogram/types/messages_and_media/sticker.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

1919
from datetime import datetime
20-
from typing import List
20+
from typing import List, Dict, Type
2121

2222
import pyrogram
2323
from pyrogram import raw, utils
@@ -146,10 +146,18 @@ async def _get_sticker_set_name(invoke, input_sticker_set_id):
146146
async def _parse(
147147
client,
148148
sticker: "raw.types.Document",
149-
image_size_attributes: "raw.types.DocumentAttributeImageSize",
150-
sticker_attributes: "raw.types.DocumentAttributeSticker",
151-
file_name: str
149+
document_attributes: Dict[Type["raw.base.DocumentAttribute"], "raw.base.DocumentAttribute"],
152150
) -> "Sticker":
151+
sticker_attributes = (
152+
document_attributes[raw.types.DocumentAttributeSticker]
153+
if raw.types.DocumentAttributeSticker in document_attributes
154+
else document_attributes[raw.types.DocumentAttributeCustomEmoji]
155+
)
156+
157+
image_size_attributes = document_attributes.get(raw.types.DocumentAttributeImageSize, None)
158+
file_name = getattr(document_attributes.get(raw.types.DocumentAttributeFilename, None), "file_name", None)
159+
video_attributes = document_attributes.get(raw.types.DocumentAttributeVideo, None)
160+
153161
sticker_set = sticker_attributes.stickerset
154162

155163
if isinstance(sticker_set, raw.types.InputStickerSetID):
@@ -170,8 +178,20 @@ async def _parse(
170178
file_unique_type=FileUniqueType.DOCUMENT,
171179
media_id=sticker.id
172180
).encode(),
173-
width=image_size_attributes.w if image_size_attributes else 512,
174-
height=image_size_attributes.h if image_size_attributes else 512,
181+
width=(
182+
image_size_attributes.w
183+
if image_size_attributes
184+
else video_attributes.w
185+
if video_attributes
186+
else 512
187+
),
188+
height=(
189+
image_size_attributes.h
190+
if image_size_attributes
191+
else video_attributes.h
192+
if video_attributes
193+
else 512
194+
),
175195
is_animated=sticker.mime_type == "application/x-tgsticker",
176196
is_video=sticker.mime_type == "video/webm",
177197
# TODO: mask_position

0 commit comments

Comments
 (0)