Skip to content

Commit 2eb540b

Browse files
committed
Update API Scheme to Layer 196, from TDLib
1 parent 372429a commit 2eb540b

File tree

9 files changed

+99
-74
lines changed

9 files changed

+99
-74
lines changed

compiler/api/source/main_api.tl

Lines changed: 52 additions & 29 deletions
Large diffs are not rendered by default.

docs/source/releases/changes-in-this-fork.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ Breaking Changes in this Fork
2121
Changes in this Fork
2222
=====================
2323

24+
+------------------------+
25+
| Scheme layer used: 196 |
26+
+------------------------+
27+
28+
- Added the parameters ``can_be_upgraded``, ``was_refunded``, ``prepaid_upgrade_star_count`` in :obj:`~pyrogram.types.UserGift`.
29+
- Renamed the parameter ``only_in_channels`` to ``chat_type_filter`` in the :meth:`~pyrogram.Client.search_global_count` and :meth:`~pyrogram.Client.search_global`.
30+
- Removed ``sender_user_id`` parameter from :meth:`~pyrogram.Client.sell_gift` and :meth:`~pyrogram.Client.toggle_gift_is_saved`.
31+
- View `new and changed <https://telegramplayground.github.io/TG-APIs/TL/diff/tdlib.html?from=195&to=196>`__ `raw API methods <https://telegramplayground.github.io/TG-APIs/TL/diff/tdesktop.html?from=195&to=196>`__.
32+
2433
+------------------------+
2534
| Scheme layer used: 195 |
2635
+------------------------+

pyrogram/enums/chat_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ChatType(AutoName):
3131
"Chat is a private chat with a bot"
3232

3333
GROUP = auto()
34-
"Chat is a basic group"
34+
"Chat is a group"
3535

3636
SUPERGROUP = auto()
3737
"Chat is a supergroup"

pyrogram/methods/business/get_user_gifts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async def get_user_gifts(
7070
offset=offset,
7171
limit=limit
7272
),
73-
sleep_threshold=max(60, self.sleep_threshold)
73+
sleep_threshold=60
7474
)
7575

7676
users = {u.id: u for u in r.users}

pyrogram/methods/business/sell_gift.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,13 @@
2626
class SellGift:
2727
async def sell_gift(
2828
self: "pyrogram.Client",
29-
sender_user_id: Union[int, str],
3029
message_id: int
3130
) -> bool:
3231
"""Sells a gift received by the current user for Telegram Stars.
3332
3433
.. include:: /_includes/usable-by/users.rst
3534
3635
Parameters:
37-
sender_user_id (``int`` | ``str``):
38-
Unique identifier (int) or username (str) of the user that sent the gift.
39-
For your personal cloud (Saved Messages) you can simply use "me" or "self".
40-
For a contact that exists in your Telegram address book you can use his phone number (str).
41-
4236
message_id (``int``):
4337
Unique identifier of the message with the gift in the chat with the user.
4438
@@ -49,19 +43,12 @@ async def sell_gift(
4943
.. code-block:: python
5044
5145
# Convert gift
52-
app.sell_gift(sender_user_id=user_id, message_id=123)
46+
app.sell_gift(message_id=123)
5347
5448
"""
55-
peer = await self.resolve_peer(sender_user_id)
56-
57-
if not isinstance(peer, (raw.types.InputPeerUser, raw.types.InputPeerSelf)):
58-
raise ValueError("sender_user_id must belong to a user.")
5949

60-
r = await self.invoke(
50+
return await self.invoke(
6151
raw.functions.payments.ConvertStarGift(
62-
user_id=peer,
6352
msg_id=message_id
6453
)
6554
)
66-
67-
return r

pyrogram/methods/business/toggle_gift_is_saved.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
class ToggleGiftIsSaved:
2727
async def toggle_gift_is_saved(
2828
self: "pyrogram.Client",
29-
sender_user_id: Union[int, str],
3029
message_id: int,
3130
is_saved: bool
3231
) -> bool:
@@ -35,11 +34,6 @@ async def toggle_gift_is_saved(
3534
.. include:: /_includes/usable-by/users.rst
3635
3736
Parameters:
38-
sender_user_id (``int`` | ``str``):
39-
Unique identifier (int) or username (str) of the target user that sent the gift.
40-
For your personal cloud (Saved Messages) you can simply use "me" or "self".
41-
For a contact that exists in your Telegram address book you can use his phone number (str).
42-
4337
message_id (``int``):
4438
Unique message identifier of the message with the gift in the chat with the user.
4539
@@ -53,19 +47,12 @@ async def toggle_gift_is_saved(
5347
.. code-block:: python
5448
5549
# Hide gift
56-
app.toggle_gift_is_saved(sender_user_id=user_id, message_id=123, is_saved=False)
50+
app.toggle_gift_is_saved(message_id=123, is_saved=False)
5751
"""
58-
peer = await self.resolve_peer(sender_user_id)
59-
60-
if not isinstance(peer, (raw.types.InputPeerUser, raw.types.InputPeerSelf)):
61-
raise ValueError("sender_user_id must belong to a user.")
6252

63-
r = await self.invoke(
53+
return await self.invoke(
6454
raw.functions.payments.SaveStarGift(
65-
user_id=peer,
6655
msg_id=message_id,
6756
unsave=not is_saved
6857
)
6958
)
70-
71-
return r

pyrogram/methods/messages/search_global.py

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

2121
import pyrogram
22-
from pyrogram import raw, enums
23-
from pyrogram import types
24-
from pyrogram import utils
22+
from pyrogram import raw, enums, types, utils
2523

2624

2725
class SearchGlobal:
@@ -31,7 +29,7 @@ async def search_global(
3129
filter: "enums.MessagesFilter" = enums.MessagesFilter.EMPTY,
3230
limit: int = 0,
3331
chat_list: int = 0,
34-
only_in_channels: bool = False,
32+
chat_type_filter: "enums.ChatType" = None,
3533
) -> Optional[AsyncGenerator["types.Message", None]]:
3634
"""Search messages globally from all of your chats.
3735
@@ -60,9 +58,8 @@ async def search_global(
6058
chat_list (``int``, *optional*):
6159
Chat list in which to search messages; Only Main (0) and Archive (1) chat lists are supported. Defaults to (0) Main chat list.
6260
63-
only_in_channels (``bool``, *optional*):
64-
True, if should search only in joined channels.
65-
Defaults to False. All available chats are searched.
61+
chat_type_filter (:obj:`~pyrogram.enums.ChatType`, *optional*):
62+
Additional filter for type of the chat (:obj:`~pyrogram.enums.ChatType.PRIVATE`, :obj:`~pyrogram.enums.ChatType.GROUP`, :obj:`~pyrogram.enums.ChatType.CHANNEL`) of the searched messages; pass None to search for messages in all chats.
6663
6764
Returns:
6865
``Generator``: A generator yielding :obj:`~pyrogram.types.Message` objects.
@@ -97,13 +94,16 @@ async def search_global(
9794
q=query,
9895
filter=filter.value(),
9996
min_date=0,
97+
# TODO
10098
max_date=0,
10199
offset_rate=offset_date,
102100
offset_peer=offset_peer,
103101
offset_id=offset_id,
104102
limit=limit,
105103
folder_id=chat_list,
106-
broadcasts_only=only_in_channels
104+
broadcasts_only=(chat_type_filter == enums.ChatType.CHANNEL) if chat_type_filter else None,
105+
groups_only=(chat_type_filter == enums.ChatType.GROUP) if chat_type_filter else None,
106+
users_only=(chat_type_filter == enums.ChatType.PRIVATE) if chat_type_filter else None,
107107
),
108108
sleep_threshold=60
109109
),

pyrogram/methods/messages/search_global_count.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async def search_global_count(
2626
query: str = "",
2727
filter: "enums.MessagesFilter" = enums.MessagesFilter.EMPTY,
2828
chat_list: int = 0,
29-
only_in_channels: bool = False,
29+
chat_type_filter: "enums.ChatType" = None,
3030
) -> int:
3131
"""Get the count of messages resulting from a global search.
3232
@@ -45,9 +45,8 @@ async def search_global_count(
4545
chat_list (``int``, *optional*):
4646
Chat list in which to search messages; Only Main (0) and Archive (1) chat lists are supported. Defaults to (0) Main chat list.
4747
48-
only_in_channels (``bool``, *optional*):
49-
True, if should search only in joined channels.
50-
Defaults to False. All available chats are searched.
48+
chat_type_filter (:obj:`~pyrogram.enums.ChatType`, *optional*):
49+
Additional filter for type of the chat (:obj:`~pyrogram.enums.ChatType.PRIVATE`, :obj:`~pyrogram.enums.ChatType.GROUP`, :obj:`~pyrogram.enums.ChatType.CHANNEL`) of the searched messages; pass None to search for messages in all chats.
5150
5251
Returns:
5352
``int``: On success, the messages count is returned.
@@ -63,7 +62,9 @@ async def search_global_count(
6362
offset_id=0,
6463
limit=1,
6564
folder_id=chat_list,
66-
broadcasts_only=only_in_channels
65+
broadcasts_only=(chat_type_filter == enums.ChatType.CHANNEL) if chat_type_filter else None,
66+
groups_only=(chat_type_filter == enums.ChatType.GROUP) if chat_type_filter else None,
67+
users_only=(chat_type_filter == enums.ChatType.PRIVATE) if chat_type_filter else None,
6768
)
6869
)
6970

pyrogram/types/messages_and_media/user_gift.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ class UserGift(Object):
5959
was_converted (``bool``, *optional*):
6060
True, if the gift was converted to Telegram Stars; only for the receiver of the gift.
6161
62+
can_be_upgraded (``bool``, *optional*):
63+
True, if the gift is a regular gift that can be upgraded to a unique gift; only for the receiver of the gift.
64+
65+
was_refunded (``bool``, *optional*):
66+
True, if the gift was refunded and isn't available anymore.
67+
68+
prepaid_upgrade_star_count (``int``, *optional*):
69+
Number of Telegram Stars that were paid by the sender for the ability to upgrade the gift.
70+
6271
"""
6372

6473
def __init__(
@@ -75,6 +84,9 @@ def __init__(
7584
message_id: Optional[int] = None,
7685
sell_star_count: Optional[int] = None,
7786
was_converted: Optional[bool] = None,
87+
can_be_upgraded: Optional[bool] = None,
88+
was_refunded: Optional[bool] = None,
89+
prepaid_upgrade_star_count: Optional[int] = None,
7890
):
7991
super().__init__(client)
8092

@@ -88,6 +100,9 @@ def __init__(
88100
self.message_id = message_id
89101
self.sell_star_count = sell_star_count
90102
self.was_converted = was_converted
103+
self.can_be_upgraded = can_be_upgraded
104+
self.was_refunded = was_refunded
105+
self.prepaid_upgrade_star_count = prepaid_upgrade_star_count
91106

92107
@staticmethod
93108
async def _parse(
@@ -150,6 +165,9 @@ async def _parse_action(
150165
entities=entities,
151166
sell_star_count=getattr(action, "convert_stars", None),
152167
was_converted=getattr(action, "converted", None),
168+
can_be_upgraded=getattr(action, "can_upgrade", None),
169+
was_refunded=getattr(action, "refunded", None),
170+
prepaid_upgrade_star_count=getattr(action, "upgrade_stars", None),
153171
client=client
154172
)
155173

0 commit comments

Comments
 (0)