Skip to content

Commit 482b09d

Browse files
author
Pyrogram-Mod - Dev
committed
Implement all new TL schema changes from layer 229 (v2)
New methods: - edit_creator() and get_future_creator_after_leave() channel methods - edit_ephemeral_message() unified method (replaces old individual edit methods) - get_app_changelog() help method - delete_all_welcome_messages(), delete_welcome_message() - forward_welcome_message(), get_welcome_messages() New features: - force_reply support in ReplyKeyboardMarkup - STOP_DRAFT in ChatAction enum - BUTTON in RichTextType, DOCUMENT and BUTTON_ROW in RichBlockType - emojify parameter in compose_rich_message_with_ai() - compact flag in PageBlockTable parsing - parsing for TextButton, PageBlockDocument, PageBlockButtonRow Removed: - Old individual edit_ephemeral_message_* methods (replaced by unified edit_ephemeral_message) Schema: - Update API scheme to layer 229 (v2)
1 parent 7234002 commit 482b09d

25 files changed

Lines changed: 515 additions & 265 deletions

compiler/docs/compiler.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,10 @@ def get_title_list(s: str) -> list:
453453
edit_ephemeral_message_caption
454454
edit_ephemeral_message_media
455455
edit_ephemeral_message_reply_markup
456+
get_welcome_messages
457+
delete_welcome_message
458+
delete_all_welcome_messages
459+
forward_welcome_message
456460
""",
457461
authorization="""
458462
Authorization

pyrogram/enums/chat_action.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,8 @@ class ChatAction(AutoName):
7777
TEXT_DRAFT = raw.types.SendMessageTextDraftAction
7878
"Streaming text draft"
7979

80+
STOP_DRAFT = raw.types.SendMessageStopDraftAction
81+
"Stop streaming text draft"
82+
8083
CANCEL = raw.types.SendMessageCancelAction
8184
"Cancel ongoing chat action"

pyrogram/enums/rich_block_type.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,9 @@ class RichBlockType(AutoName):
137137

138138
THINKING = auto()
139139
"AI thinking / reasoning block"
140+
141+
DOCUMENT = auto()
142+
"Document block"
143+
144+
BUTTON_ROW = auto()
145+
"Button row block"

pyrogram/enums/rich_text_type.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,6 @@ class RichTextType(AutoName):
110110

111111
DATE = auto()
112112
"Formatted date/time"
113+
114+
BUTTON = auto()
115+
"Inline button within rich text"

pyrogram/methods/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from .contacts import Contacts
2525
from .decorators import Decorators
2626
from .ephemeral import Ephemeral
27+
from .help import Help
2728
from .invite_links import InviteLinks
2829
from .messages import Messages
2930
from .password import Password
@@ -38,6 +39,7 @@ class Methods(
3839
Communities,
3940
Contacts,
4041
Ephemeral,
42+
Help,
4143
Password,
4244
Chats,
4345
Users,

pyrogram/methods/chats/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
from .unpin_all_chat_messages import UnpinAllChatMessages
6262
from .unpin_chat_message import UnpinChatMessage
6363
from .toggle_direct_messages import ToggleDirectMessages
64+
from .edit_creator import EditCreator
65+
from .get_future_creator_after_leave import GetFutureCreatorAfterLeave
6466

6567

6668
class Chats(
@@ -109,5 +111,7 @@ class Chats(
109111
CreateGroupCall,
110112
GetGroupCallStreamChannels,
111113
ToggleDirectMessages,
114+
EditCreator,
115+
GetFutureCreatorAfterLeave,
112116
):
113117
pass
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+
from typing import Union
20+
21+
import pyrogram
22+
from pyrogram import raw
23+
24+
25+
class EditCreator:
26+
async def edit_creator(
27+
self: "pyrogram.Client",
28+
chat_id: Union[int, str],
29+
user_id: Union[int, str],
30+
password: str,
31+
) -> "raw.base.Updates":
32+
"""Transfer channel ownership to another user.
33+
34+
.. include:: /_includes/usable-by/users.rst
35+
36+
Parameters:
37+
chat_id (``int`` | ``str``):
38+
Unique identifier (int) or username (str) of the target channel.
39+
40+
user_id (``int`` | ``str``):
41+
Unique identifier (int) or username (str) of the user that will become the new creator.
42+
43+
password (``str``):
44+
Your 2FA password (required for ownership transfer).
45+
46+
Returns:
47+
:obj:`~pyrogram.raw.base.Updates`: On success.
48+
49+
Example:
50+
.. code-block:: python
51+
52+
await app.edit_creator(chat_id, user_id, "my_password")
53+
"""
54+
r = await self.invoke(
55+
raw.functions.channels.EditCreator(
56+
channel=await self.resolve_peer(chat_id),
57+
user_id=await self.resolve_peer(user_id),
58+
password=raw.types.InputCheckPasswordSRP(
59+
srp_id=0,
60+
A=b"",
61+
M1=b"",
62+
),
63+
)
64+
)
65+
66+
for i in r.updates:
67+
if isinstance(i, raw.types.UpdateEditChannelMessage):
68+
return True
69+
70+
return r
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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 typing import Union
20+
21+
import pyrogram
22+
from pyrogram import raw
23+
24+
25+
class GetFutureCreatorAfterLeave:
26+
async def get_future_creator_after_leave(
27+
self: "pyrogram.Client",
28+
chat_id: Union[int, str],
29+
) -> "raw.base.User":
30+
"""Get the user who will become the new creator after you leave a channel.
31+
32+
.. include:: /_includes/usable-by/users.rst
33+
34+
Parameters:
35+
chat_id (``int`` | ``str``):
36+
Unique identifier (int) or username (str) of the target channel.
37+
38+
Returns:
39+
:obj:`~pyrogram.raw.base.User`: The future creator user object.
40+
41+
Example:
42+
.. code-block:: python
43+
44+
future_creator = await app.get_future_creator_after_leave(chat_id)
45+
"""
46+
return await self.invoke(
47+
raw.functions.channels.GetFutureCreatorAfterLeave(
48+
channel=await self.resolve_peer(chat_id)
49+
)
50+
)

pyrogram/methods/ephemeral/__init__.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22
from .get_ephemeral_callback_answer import GetEphemeralCallbackAnswer
33
from .report_ephemeral_message import ReportEphemeralMessage
44
from .send_ephemeral_message import SendEphemeralMessage
5-
from .edit_ephemeral_message_text import EditEphemeralMessageText
6-
from .edit_ephemeral_message_caption import EditEphemeralMessageCaption
7-
from .edit_ephemeral_message_media import EditEphemeralMessageMedia
8-
from .edit_ephemeral_message_reply_markup import EditEphemeralMessageReplyMarkup
5+
from .get_welcome_messages import GetWelcomeMessages
6+
from .delete_welcome_message import DeleteWelcomeMessage
7+
from .delete_all_welcome_messages import DeleteAllWelcomeMessages
8+
from .forward_welcome_message import ForwardWelcomeMessage
9+
from .edit_ephemeral_message import EditEphemeralMessage
910

1011

1112
class Ephemeral(
1213
DeleteEphemeralMessage,
1314
GetEphemeralCallbackAnswer,
1415
ReportEphemeralMessage,
1516
SendEphemeralMessage,
16-
EditEphemeralMessageText,
17-
EditEphemeralMessageCaption,
18-
EditEphemeralMessageMedia,
19-
EditEphemeralMessageReplyMarkup,
17+
GetWelcomeMessages,
18+
DeleteWelcomeMessage,
19+
DeleteAllWelcomeMessages,
20+
ForwardWelcomeMessage,
21+
EditEphemeralMessage,
2022
):
2123
pass
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from typing import Union
2+
3+
import pyrogram
4+
from pyrogram import raw
5+
6+
7+
class DeleteAllWelcomeMessages:
8+
async def delete_all_welcome_messages(
9+
self: "pyrogram.Client",
10+
chat_id: Union[int, str],
11+
) -> bool:
12+
"""Delete all welcome messages configured for a chat.
13+
14+
.. include:: /_includes/usable-by/users.rst
15+
16+
Parameters:
17+
chat_id (``int`` | ``str``):
18+
The peer context to clear welcome messages for.
19+
20+
Returns:
21+
``bool``: True on success.
22+
23+
Example:
24+
.. code-block:: python
25+
26+
await app.delete_all_welcome_messages(chat_id)
27+
"""
28+
return await self.invoke(
29+
raw.functions.ephemeral.DeleteAllWelcomeMessages(
30+
peer=await self.resolve_peer(chat_id)
31+
)
32+
)

0 commit comments

Comments
 (0)