Skip to content

Commit c779fee

Browse files
committed
Merge remote-tracking branch 'KurimuzonAkuma/dev' into dev
2 parents b9df35b + abb4888 commit c779fee

6 files changed

Lines changed: 30 additions & 21 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.2.13"
19+
__version__ = "2.2.15"
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/chats/get_dialogs.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from typing import AsyncGenerator, Optional
2020

2121
import pyrogram
22-
from pyrogram import types, raw, utils
22+
from pyrogram import raw, types, utils
2323

2424

2525
class GetDialogs:
@@ -91,9 +91,9 @@ async def get_dialogs(
9191
if isinstance(message, raw.types.MessageEmpty):
9292
continue
9393

94-
chat_id = utils.get_peer_id(message.peer_id)
95-
96-
messages[chat_id] = await types.Message._parse(self, message, users, chats)
94+
messages[utils.get_peer_id(message.peer_id)] = await types.Message._parse(
95+
self, message, users, chats
96+
)
9797

9898
dialogs = []
9999

@@ -116,9 +116,9 @@ async def get_dialogs(
116116
if not dialogs:
117117
return
118118

119-
last_message = next(filter(None, (
120-
messages.get(utils.get_raw_peer_id(d.chat.id)) for d in reversed(dialogs)
121-
)), None)
119+
last_message = next(
120+
filter(None, (messages.get(d.chat.id) for d in reversed(dialogs))), None
121+
)
122122

123123
offset_id = last_message.id if last_message else 0
124124
offset_date = utils.datetime_to_timestamp(last_message.date) if last_message else 0

pyrogram/methods/stories/edit_story_media.py

Lines changed: 6 additions & 3 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
import os
20-
from typing import Union, BinaryIO, Callable
20+
from typing import List, Union, BinaryIO, Callable
2121

2222
import pyrogram
2323
from pyrogram import raw, types, utils, StopTransmission
@@ -29,6 +29,7 @@ async def edit_story_media(
2929
chat_id: Union[int, str],
3030
story_id: int,
3131
media: Union[str, BinaryIO] = None,
32+
media_areas: List["types.MediaArea"] = None,
3233
duration: int = 0,
3334
width: int = 0,
3435
height: int = 0,
@@ -56,6 +57,9 @@ async def edit_story_media(
5657
pass a file path as string to upload a new animation that exists on your local machine, or
5758
pass a binary file-like object with its attribute ".name" set for in-memory uploads.
5859
60+
media_areas (List of :obj:`~pyrogram.types.MediaArea`, *optional*):
61+
List of media areas to edit in the story.
62+
5963
duration (``int``, *optional*):
6064
Duration of sent video in seconds.
6165
@@ -94,8 +98,6 @@ async def edit_story_media(
9498
# Replace the current media with a local video
9599
await app.edit_story_media(chat_id, story_id, "new_video.mp4")
96100
"""
97-
# TODO: media_areas
98-
99101
try:
100102
if isinstance(media, str):
101103
if os.path.isfile(media):
@@ -153,6 +155,7 @@ async def edit_story_media(
153155
peer=await self.resolve_peer(chat_id),
154156
id=story_id,
155157
media=media,
158+
media_areas=[await area.write(self) for area in (media_areas or [])] or None,
156159
)
157160
)
158161
except FilePartXMissing as e:

pyrogram/methods/stories/send_story.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ async def send_story(
3131
media: Union[str, BinaryIO],
3232
caption: str = None,
3333
period: int = None,
34+
media_areas: List["types.MediaArea"] = None,
3435
duration: int = 0,
3536
width: int = 0,
3637
height: int = 0,
@@ -46,7 +47,6 @@ async def send_story(
4647
caption_entities: List["types.MessageEntity"] = None,
4748
progress: Callable = None,
4849
progress_args: tuple = (),
49-
media_areas: List["types.MediaArea"] = None
5050
) -> "types.Story":
5151
"""Post new story.
5252
@@ -71,6 +71,9 @@ async def send_story(
7171
Must be one of ``6 * 3600``, ``12 * 3600``, ``86400``, or ``2 * 86400`` for Telegram Premium users,
7272
and 86400 otherwise.
7373
74+
media_areas (List of :obj:`~pyrogram.types.MediaArea`, *optional*):
75+
List of media areas to add to the story.
76+
7477
duration (``int``, *optional*):
7578
Duration of sent video in seconds.
7679
@@ -132,9 +135,6 @@ async def send_story(
132135
You can pass anything you need to be available in the progress callback scope; for example, a Message
133136
object or a Client instance in order to edit the message with the updated progress status.
134137
135-
media_areas (List of :obj:`~pyrogram.types.MediaArea`, *optional*):
136-
List of media areas to add to the story.
137-
138138
Returns:
139139
:obj:`~pyrogram.types.Story` a single story is returned.
140140
@@ -150,8 +150,6 @@ async def send_story(
150150
Raises:
151151
ValueError: In case of invalid arguments.
152152
"""
153-
# TODO: media_areas
154-
155153
message, entities = (await utils.parse_text_entities(self, caption, parse_mode, caption_entities)).values()
156154

157155
try:

pyrogram/types/messages_and_media/gift.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ class Gift(Object):
8383
host_id (``int``, *optional*):
8484
Identifier of the user or the chat to which the upgraded gift was assigned from blockchain.
8585
86+
host (:obj:`~pyrogram.types.Chat`, *optional*):
87+
User or the chat to which the upgraded gift was assigned from blockchain.
88+
8689
owner (:obj:`~pyrogram.types.Chat`, *optional*):
8790
Current gift owner.
8891
@@ -224,6 +227,7 @@ def __init__(
224227
locked_until_date: Optional[datetime] = None,
225228
from_user: Optional["types.User"] = None,
226229
host_id: Optional[int] = None,
230+
host: Optional["types.Chat"] = None,
227231
owner: Optional["types.Chat"] = None,
228232
owner_name: Optional[str] = None,
229233
owner_address: Optional[str] = None,
@@ -283,6 +287,7 @@ def __init__(
283287
self.locked_until_date = locked_until_date
284288
self.from_user = from_user
285289
self.host_id = host_id
290+
self.host = host
286291
self.owner = owner
287292
self.owner_name = owner_name
288293
self.owner_address = owner_address
@@ -334,7 +339,7 @@ async def _parse(client, gift, users: Dict[int, "raw.base.User"] = {}, chats: Di
334339
return await Gift._parse_regular(client, gift, users, chats)
335340
elif isinstance(gift, raw.types.StarGiftUnique):
336341
return await Gift._parse_unique(client, gift, users, chats)
337-
elif isinstance(gift, raw.types.StarGiftSaved):
342+
elif isinstance(gift, raw.types.SavedStarGift):
338343
return await Gift._parse_saved(client, gift, users, chats)
339344

340345
@staticmethod
@@ -383,7 +388,8 @@ async def _parse_unique(
383388
if not isinstance(star_gift, raw.types.StarGiftUnique):
384389
return
385390

386-
owner_id = utils.get_raw_peer_id(star_gift.owner_id)
391+
raw_host_id = utils.get_raw_peer_id(star_gift.host_id)
392+
raw_owner_id = utils.get_raw_peer_id(star_gift.owner_id)
387393

388394
return Gift(
389395
id=star_gift.id,
@@ -401,7 +407,8 @@ async def _parse_unique(
401407
is_theme_available=star_gift.theme_available,
402408
used_theme_chat_id=utils.get_peer_id(star_gift.theme_peer) if star_gift.theme_peer else None,
403409
host_id=utils.get_peer_id(star_gift.host_id) if star_gift.host_id else None,
404-
owner=types.Chat._parse_chat(client, users.get(owner_id) or chats.get(owner_id)),
410+
host=types.Chat._parse_chat(client, users.get(raw_host_id) or chats.get(raw_host_id)),
411+
owner=types.Chat._parse_chat(client, users.get(raw_owner_id) or chats.get(raw_owner_id)),
405412
owner_name=star_gift.owner_name,
406413
owner_address=star_gift.owner_address,
407414
gift_address=star_gift.gift_address,

pyrogram/types/user_and_chats/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from .chat_member_updated import ChatMemberUpdated
3939
from .chat_permissions import ChatPermissions
4040
from .chat_photo import ChatPhoto
41-
from .chat_administrator_rights import ChatAdministratorRights
41+
from .chat_administrator_rights import ChatAdministratorRights, ChatPrivileges
4242
from .chat_reactions import ChatReactions
4343
from .chat_settings import ChatSettings
4444
from .dialog import Dialog
@@ -102,6 +102,7 @@
102102
"VideoChatScheduled",
103103
"ChatJoinRequest",
104104
"ChatAdministratorRights",
105+
"ChatPrivileges",
105106
"ChatJoiner",
106107
"EmojiStatus",
107108
"FailedToAddMember",

0 commit comments

Comments
 (0)