Skip to content

Commit f27f2df

Browse files
Update methods and types to layer 218
1 parent 712e725 commit f27f2df

19 files changed

Lines changed: 645 additions & 25 deletions

compiler/docs/compiler.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ def get_title_list(s: str) -> list:
444444
convert_gift_to_stars
445445
get_available_gifts
446446
get_chat_gifts
447+
get_gift_auction_state
447448
get_chat_gifts_count
448449
add_collection_gifts
449450
create_gift_collection
@@ -464,6 +465,8 @@ def get_title_list(s: str) -> list:
464465
get_upgraded_gift
465466
gift_premium_with_stars
466467
hide_gift
468+
increase_gift_auction_bid
469+
place_gift_auction_bid
467470
search_gifts_for_resale
468471
send_gift
469472
send_payment_form
@@ -801,6 +804,12 @@ def get_title_list(s: str) -> list:
801804
InputChatPhotoPrevious
802805
InputChatPhotoStatic
803806
InputChatPhotoAnimation
807+
AuctionBid
808+
AuctionState
809+
AuctionStateActive
810+
AuctionStateFinished
811+
GiftAuctionState
812+
GiftAuction
804813
""",
805814
bot_keyboards="""
806815
Bot keyboards
@@ -1095,6 +1104,7 @@ def get_title_list(s: str) -> list:
10951104
Gift.wear
10961105
Gift.buy
10971106
Gift.send
1107+
Gift.get_auction_state
10981108
""",
10991109
animation="""
11001110
Animation
@@ -1152,6 +1162,7 @@ def get_title_list(s: str) -> list:
11521162
MessageServiceType
11531163
MessagesFilter
11541164
NextCodeType
1165+
PaidReactionPrivacy
11551166
ParseMode
11561167
PhoneCallDiscardReason
11571168
PollType

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ dev = [
6767
]
6868

6969
docs = [
70-
"Sphinx<=9.0.0",
71-
"shibuya<=2025.11.10",
70+
"Sphinx<=9.0.4",
71+
"shibuya<=2025.12.17",
7272
"sphinx-autobuild<=2025.8.25",
7373
"sphinx-copybutton<=0.5.2",
74+
"sphinx-iconify<=0.2.1",
75+
"sphinx-design<=0.6.1",
7476
"pygments<=2.19.2",
7577
]
7678

pyrogram/methods/chats/toggle_forum_topics.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@ async def toggle_forum_topics(
3737
chat_id (``int`` | ``str``):
3838
Unique identifier (int) or username (str) of the target chat.
3939
40-
enabled (``bool``):
41-
The new status. Pass True to enable forum topics.
40+
is_forum (``bool``):
41+
The new status.
42+
Pass True to enable forum topics.
43+
Defaults to False.
4244
4345
has_forum_tabs (``bool``):
44-
Whether to enable or disable tabs in the forum. Defaults to False.
46+
Whether to enable or disable tabs in the forum.
47+
Defaults to False.
4548
4649
Returns:
4750
``bool``: True on success. False otherwise.
@@ -50,7 +53,7 @@ async def toggle_forum_topics(
5053
.. code-block:: python
5154
5255
# Change status of topics to disabled
53-
await app.toggle_forum_topics()
56+
await app.toggle_forum_topics(is_forum=False)
5457
5558
# Change status of topics to enabled
5659
await app.toggle_forum_topics(is_forum=True)

pyrogram/methods/payments/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from .edit_star_subscription import EditStarSubscription
2828
from .get_available_gifts import GetAvailableGifts
2929
from .get_chat_gifts import GetChatGifts
30+
from .get_gift_auction_state import GetGiftAuctionState
3031
from .get_chat_gifts_count import GetChatGiftsCount
3132
from .get_gift_collections import GetGiftCollections
3233
from .get_gift_upgrade_preview import GetGiftUpgradePreview
@@ -37,6 +38,8 @@
3738
from .get_upgraded_gift_value_info import GetUpgradedGiftValueInfo
3839
from .gift_premium_with_stars import GiftPremiumWithStars
3940
from .hide_gift import HideGift
41+
from .increase_gift_auction_bid import IncreaseGiftAuctionBid
42+
from .place_gift_auction_bid import PlaceGiftAuctionBid
4043
from .remove_collection_gifts import RemoveCollectionGifts
4144
from .reorder_collection_gifts import ReorderCollectionGifts
4245
from .reorder_gift_collections import ReorderGiftCollections
@@ -66,6 +69,7 @@ class Payments(
6669
EditStarSubscription,
6770
GetAvailableGifts,
6871
GetChatGifts,
72+
GetGiftAuctionState,
6973
GetChatGiftsCount,
7074
GetGiftCollections,
7175
GetGiftUpgradePreview,
@@ -76,6 +80,8 @@ class Payments(
7680
GetUpgradedGiftValueInfo,
7781
GiftPremiumWithStars,
7882
HideGift,
83+
IncreaseGiftAuctionBid,
84+
PlaceGiftAuctionBid,
7985
RemoveCollectionGifts,
8086
ReorderCollectionGifts,
8187
ReorderGiftCollections,

pyrogram/methods/payments/get_chat_gifts_count.py

Lines changed: 1 addition & 1 deletion
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 logging
20-
from typing import Optional, Union
20+
from typing import Union
2121

2222
import pyrogram
2323
from pyrogram import raw
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
import logging
20+
import re
21+
from typing import Union
22+
23+
import pyrogram
24+
from pyrogram import raw, types
25+
26+
log = logging.getLogger(__name__)
27+
28+
29+
class GetGiftAuctionState:
30+
async def get_gift_auction_state(
31+
self: "pyrogram.Client", auction_id: Union[str, int]
32+
) -> "types.GiftAuctionState":
33+
"""Returns auction state for a gift.
34+
35+
.. include:: /_includes/usable-by/users.rst
36+
37+
Parameters:
38+
auction_id (``str`` | ``int``):
39+
Unique identifier of the auction, auction link or gift id.
40+
41+
Returns:
42+
:obj:`~pyrogram.types.GiftAuctionState`: On success, the auction state is returned.
43+
"""
44+
if isinstance(auction_id, int):
45+
auction = raw.types.InputStarGiftAuction(gift_id=auction_id)
46+
else:
47+
match = re.match(r"^(?:https?://)?(?:www\.)?(?:t(?:elegram)?\.(?:org|me|dog)/(?:auction/))([\w-]+)$", auction_id)
48+
49+
if match:
50+
slug = match.group(1)
51+
elif isinstance(auction_id, str):
52+
slug = auction_id
53+
else:
54+
raise ValueError("Invalid auction link")
55+
56+
auction=raw.types.InputStarGiftAuctionSlug(slug=slug)
57+
58+
r = await self.invoke(
59+
raw.functions.payments.GetStarGiftAuctionState(
60+
auction=auction, version=0
61+
)
62+
)
63+
64+
return await types.GiftAuctionState._parse(self, r)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
import pyrogram
20+
from pyrogram import raw
21+
22+
23+
class IncreaseGiftAuctionBid:
24+
async def increase_gift_auction_bid(
25+
self: "pyrogram.Client",
26+
gift_id: int,
27+
star_count: int
28+
) -> bool:
29+
"""Increases a bid for an auction gift without changing gift text and receiver.
30+
31+
.. include:: /_includes/usable-by/users.rst
32+
33+
Parameters:
34+
gift_id (``int``):
35+
Identifier of the gift to put the bid on.
36+
37+
star_count (``int``):
38+
The number of Telegram Stars to put in the bid.
39+
40+
Returns:
41+
``bool``: On success, True is returned.
42+
"""
43+
invoice = raw.types.InputInvoiceStarGiftAuctionBid(
44+
gift_id=gift_id,
45+
bid_amount=star_count,
46+
update_bid=True
47+
)
48+
49+
form = await self.invoke(
50+
raw.functions.payments.GetPaymentForm(
51+
invoice=invoice
52+
)
53+
)
54+
55+
if star_count < 0:
56+
raise ValueError("Invalid amount of Telegram Stars specified.")
57+
58+
if form.invoice.prices[0].amount > star_count:
59+
raise ValueError("Have not enough Telegram Stars.")
60+
61+
r = await self.invoke(
62+
raw.functions.payments.SendStarsForm(
63+
form_id=form.form_id,
64+
invoice=invoice
65+
)
66+
)
67+
68+
return isinstance(r, raw.types.payments.PaymentResult)
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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 typing import Optional, Union
21+
22+
import pyrogram
23+
from pyrogram import raw, types
24+
25+
26+
class PlaceGiftAuctionBid:
27+
async def place_gift_auction_bid(
28+
self: "pyrogram.Client",
29+
gift_id: int,
30+
star_count: int,
31+
user_id: Optional[Union[int, str]] = None,
32+
text: Optional["types.FormattedText"] = None,
33+
is_private: Optional[bool] = False,
34+
) -> bool:
35+
"""Places a bid on an auction gift.
36+
37+
.. include:: /_includes/usable-by/users.rst
38+
39+
Parameters:
40+
gift_id (``int``):
41+
Identifier of the gift to place the bid on.
42+
43+
star_count (``int``):
44+
The number of Telegram Stars to place in the bid.
45+
46+
user_id (``int`` | ``str``, *optional*):
47+
Unique identifier (int) or username (str) of the target chat you want to transfer the star gift to.
48+
For your personal cloud (Saved Messages) you can simply use "me" or "self".
49+
For a contact that exists in your Telegram address book you can use his phone number (str).
50+
51+
text (:obj:`~pyrogram.types.FormattedText`, *optional*):
52+
Text to show along with the gift.
53+
Must be empty if the receiver enabled paid messages.
54+
55+
is_private (``bool``, *optional*):
56+
Pass True to show gift text and sender only to the gift receiver, otherwise, everyone will be able to see them.
57+
58+
Returns:
59+
``bool``: On success, True is returned.
60+
61+
Example:
62+
.. code-block:: python
63+
64+
# Place a bid of 100 stars on a gift auction for yourself
65+
await app.place_gift_auction_bid(
66+
gift_id=12345,
67+
star_count=100
68+
)
69+
70+
# Place a bid of 250 stars on a gift auction for another user with a message
71+
await app.place_gift_auction_bid(
72+
gift_id=12345,
73+
star_count=250,
74+
user_id="@KurimuzonAkuma",
75+
text=types.FormattedText(
76+
text="Here's a gift for you!"
77+
)
78+
)
79+
"""
80+
invoice = raw.types.InputInvoiceStarGiftAuctionBid(
81+
gift_id=gift_id,
82+
bid_amount=star_count,
83+
hide_name=is_private,
84+
update_bid=False,
85+
peer=await self.resolve_peer(user_id or "me"),
86+
message=await text.write() if text else None
87+
)
88+
89+
form = await self.invoke(
90+
raw.functions.payments.GetPaymentForm(
91+
invoice=invoice
92+
)
93+
)
94+
95+
if star_count < 0:
96+
raise ValueError("Invalid amount of Telegram Stars specified.")
97+
98+
if form.invoice.prices[0].amount > star_count:
99+
raise ValueError("Have not enough Telegram Stars.")
100+
101+
r = await self.invoke(
102+
raw.functions.payments.SendStarsForm(
103+
form_id=form.form_id,
104+
invoice=invoice
105+
)
106+
)
107+
108+
return isinstance(r, raw.types.payments.PaymentResult)

0 commit comments

Comments
 (0)