Skip to content

Commit b9df35b

Browse files
committed
Merge remote-tracking branch 'KurimuzonAkuma/dev' into dev
# Conflicts: # compiler/errors/source/400_BAD_REQUEST.tsv # compiler/errors/source/403_FORBIDDEN.tsv
2 parents 9e0079c + 2481ea4 commit b9df35b

17 files changed

Lines changed: 520 additions & 271 deletions

File tree

.github/workflows/python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
os: [ubuntu-latest, macos-latest]
12-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
12+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
1313

1414
steps:
1515
- uses: actions/checkout@v4

compiler/docs/compiler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,12 @@ def get_title_list(s: str) -> list:
449449
create_gift_collection
450450
delete_gift_collection
451451
drop_gift_original_details
452+
edit_star_subscription
452453
get_gift_collections
453454
remove_collection_gifts
454455
reorder_collection_gifts
455456
reorder_gift_collections
457+
reuse_star_subscription
456458
set_gift_collection_name
457459
get_gift_upgrade_preview
458460
get_payment_form
@@ -497,6 +499,7 @@ def get_title_list(s: str) -> list:
497499
set_bot_commands
498500
get_bot_commands
499501
delete_bot_commands
502+
edit_user_star_subscription
500503
set_bot_default_privileges
501504
get_bot_default_privileges
502505
set_chat_menu_button

compiler/errors/source/400_BAD_REQUEST.tsv

Lines changed: 299 additions & 230 deletions
Large diffs are not rendered by default.
Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,59 @@
11
id message
2-
ALLOW_PAYMENT_REQUIRED_X This peer charges {value} [Telegram Stars](https://core.telegram.org/api/stars) per message, but the `allow_paid_stars` was not set or its value is smaller than {value}.
2+
ALLOW_PAYMENT_REQUIRED_X The user has enabled paid messages with {value} stars.
33
ANONYMOUS_REACTIONS_DISABLED Sorry, anonymous administrators cannot leave reactions or participate in polls.
4-
BROADCAST_FORBIDDEN Channel poll voters and reactions cannot be fetched to prevent deanonymization.
5-
CHANNEL_PUBLIC_GROUP_NA channel/supergroup not available.
4+
BOT_ACCESS_FORBIDDEN You can't access this bot.
5+
BOT_OWNER_REQUIRED You must be the owner of the bot to perform this action.
6+
BROADCAST_FORBIDDEN This request can't be used in channels.
7+
CHANNEL_PUBLIC_GROUP_NA The channel/supergroup is not available.
68
CHAT_ACTION_FORBIDDEN You cannot execute this action.
7-
CHAT_ADMIN_INVITE_REQUIRED You do not have the rights to do this.
9+
CHAT_ADMIN_INVITE_REQUIRED You don't have rights to invite other users.
810
CHAT_ADMIN_REQUIRED You must be an admin in this chat to do this.
911
CHAT_FORBIDDEN This chat is not available to the current user.
10-
CHAT_GUEST_SEND_FORBIDDEN You join the discussion group before commenting, see [here »](https://core.telegram.org/api/discussion#requiring-users-to-join-the-group) for more info.
12+
CHAT_GUEST_SEND_FORBIDDEN You need to join the discussion group before commenting, see [here »](https://core.telegram.org/api/discussion#requiring-users-to-join-the-group) for more info.
1113
CHAT_SEND_AUDIOS_FORBIDDEN You can't send audio messages in this chat.
1214
CHAT_SEND_DOCS_FORBIDDEN You can't send documents in this chat.
1315
CHAT_SEND_GAME_FORBIDDEN You can't send a game to this chat.
14-
CHAT_SEND_GIFS_FORBIDDEN You can't send gifs in this chat.
15-
CHAT_SEND_INLINE_FORBIDDEN You can't send inline messages in this group.
16-
CHAT_SEND_MEDIA_FORBIDDEN You can't send media in this chat.
16+
CHAT_SEND_GIFS_FORBIDDEN You can't send animations in this chat.
17+
CHAT_SEND_INLINE_FORBIDDEN You cannot use inline bots to send messages in this chat.
18+
CHAT_SEND_MEDIA_FORBIDDEN You can't send media messages in this chat.
1719
CHAT_SEND_PHOTOS_FORBIDDEN You can't send photos in this chat.
1820
CHAT_SEND_PLAIN_FORBIDDEN You can't send non-media (text) messages in this chat.
1921
CHAT_SEND_POLL_FORBIDDEN You can't send polls in this chat.
20-
CHAT_SEND_ROUNDVIDEOS_FORBIDDEN You can't send round videos to this chat.
22+
CHAT_SEND_ROUNDVIDEOS_FORBIDDEN You can't send video notes in this chat.
2123
CHAT_SEND_STICKERS_FORBIDDEN You can't send stickers in this chat.
2224
CHAT_SEND_VIDEOS_FORBIDDEN You can't send videos in this chat.
2325
CHAT_SEND_VOICES_FORBIDDEN You can't send voice recordings in this chat.
24-
CHAT_SEND_WEBPAGE_FORBIDDEN You can't send webpage previews to this chat.
25-
CHAT_TYPE_INVALID The specified user type is invalid.
26-
CHAT_WRITE_FORBIDDEN You can't write in this chat.
26+
CHAT_TYPE_INVALID The specified chat type is invalid.
27+
CHAT_WRITE_FORBIDDEN You don't have rights to send messages in this chat.
2728
EDIT_BOT_INVITE_FORBIDDEN Normal users can't edit invites that were created by bots.
2829
GROUPCALL_ALREADY_STARTED The groupcall has already started, you can join directly using [phone.joinGroupCall](https://core.telegram.org/method/phone.joinGroupCall).
2930
GROUPCALL_FORBIDDEN The group call has already ended.
30-
INLINE_BOT_REQUIRED Only the inline bot can edit message.
31-
MESSAGE_AUTHOR_REQUIRED Message author required.
32-
MESSAGE_DELETE_FORBIDDEN You can't delete one of the messages you tried to delete, most likely because it is a service message.
33-
NOT_ELIGIBLE The current user is not eligible to join the Peer-to-Peer Login Program.
31+
INLINE_BOT_REQUIRED The action must be performed through an inline bot callback.
32+
LIVE_DISABLED Story is disabled server-side.
33+
MESSAGE_AUTHOR_REQUIRED You are not the author of this message.
34+
MESSAGE_DELETE_FORBIDDEN You don't have rights to delete one of the messages you tried to delete, most likely because it is a service message or you are not the author of them.
35+
NOT_ALLOWED Not allowed.
36+
NOT_ELIGIBLE The current user is not eligible for this action.
3437
PARTICIPANT_JOIN_MISSING Trying to enable a presentation, when the user hasn't joined the Video Chat with [phone.joinGroupCall](https://core.telegram.org/method/phone.joinGroupCall).
3538
PEER_ID_INVALID The provided peer id is invalid.
3639
POLL_VOTE_REQUIRED Cast a vote in the poll before calling this method.
3740
PREMIUM_ACCOUNT_REQUIRED A premium account is required to execute this action.
38-
PRIVACY_PREMIUM_REQUIRED You need a [Telegram Premium subscription](https://core.telegram.org/api/premium) to send a message to this user.
41+
PRIVACY_PREMIUM_REQUIRED The user has restricted from sending messages or this action requires a [Telegram Premium subscription](https://core.telegram.org/api/premium).
3942
PUBLIC_CHANNEL_MISSING You can only export group call invite links for public chats or channels.
40-
RIGHT_FORBIDDEN Your admin rights do not allow you to do this.
41-
SENSITIVE_CHANGE_FORBIDDEN You can't change your sensitive content settings.
42-
TAKEOUT_REQUIRED A [takeout](https://core.telegram.org/api/takeout) session needs to be initialized first, [see here » for more info](https://core.telegram.org/api/takeout).
43+
RECAPTCHA_CHECK_X The request can't be completed unless reCAPTCHA verification {value} is performed.
44+
RIGHT_FORBIDDEN You don't have enough rights for this action, or you tried to set one or more admin rights that can't be applied to this kind of chat (channel or supergroup).
45+
SENSITIVE_CHANGE_FORBIDDEN You can't change your sensitive content settings at this time.
46+
STARGIFT_CONVERT_BOT_NOT_ALLOWED You can't convert this gift to stars.
47+
TAKEOUT_REQUIRED The method must be invoked inside a [takeout](https://core.telegram.org/api/takeout) session.
4348
USER_BOT_INVALID User accounts must provide the `bot` method parameter when calling this method. If there is no such method parameter, this method can only be invoked by bot accounts.
4449
USER_CHANNELS_TOO_MUCH One of the users you tried to add is already in too many channels/supergroups.
4550
USER_DELETED You can't send this secret message because the other participant deleted their account.
46-
USER_INVALID Invalid user provided.
51+
USER_DISALLOWED_STARGIFTS You can't send gifts to this user due to their privacy settings.
52+
USER_INVALID The provided user is invalid.
4753
USER_IS_BLOCKED You were blocked by this user.
4854
USER_NOT_MUTUAL_CONTACT The provided user is not a mutual contact.
4955
USER_NOT_PARTICIPANT You're not a member of this supergroup/channel.
5056
USER_PRIVACY_RESTRICTED The user's privacy settings do not allow you to do this.
51-
USER_RESTRICTED You're spamreported, you can't create channels or chats.
57+
USER_RESTRICTED You're limited/restricted by telegram. You can't perform this action.
5258
VOICE_MESSAGES_FORBIDDEN This user's privacy settings forbid you from sending voice messages.
5359
YOUR_PRIVACY_RESTRICTED You cannot fetch the read date of this message because you have disallowed other users to do so for *your* messages; to fix, allow other users to see *your* exact last online date OR purchase a [Telegram Premium](https://core.telegram.org/api/premium) subscription.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ classifiers = [
2424
"Programming Language :: Python :: 3.11",
2525
"Programming Language :: Python :: 3.12",
2626
"Programming Language :: Python :: 3.13",
27+
"Programming Language :: Python :: 3.14",
2728
"Programming Language :: Python :: Implementation",
2829
"Programming Language :: Python :: Implementation :: CPython",
2930
"Programming Language :: Python :: Implementation :: PyPy",

pyrogram/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ def __init__(
425425
if isinstance(loop, asyncio.AbstractEventLoop):
426426
self.loop = loop
427427
else:
428-
self.loop = asyncio.get_event_loop()
428+
self.loop = utils.get_event_loop()
429429

430430
self.__config: "raw.types.Config" = None
431431

pyrogram/connection/connection.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import logging
2121
from typing import Optional, Type
2222

23+
from pyrogram import utils
24+
2325
from .transport import TCP, TCPAbridged
2426

2527
log = logging.getLogger(__name__)
@@ -55,7 +57,7 @@ def __init__(
5557
if isinstance(loop, asyncio.AbstractEventLoop):
5658
self.loop = loop
5759
else:
58-
self.loop = asyncio.get_event_loop()
60+
self.loop = utils.get_event_loop()
5961

6062
async def connect(self) -> None:
6163
attempts = Connection.MAX_CONNECTION_ATTEMPTS

pyrogram/connection/transport/tcp/tcp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
import socks
2727

28+
from pyrogram import utils
29+
2830
log = logging.getLogger(__name__)
2931

3032
proxy_type_by_scheme: Dict[str, int] = {
@@ -68,7 +70,7 @@ def __init__(
6870
if isinstance(loop, asyncio.AbstractEventLoop):
6971
self.loop = loop
7072
else:
71-
self.loop = asyncio.get_event_loop()
73+
self.loop = utils.get_event_loop()
7274

7375
async def _connect_via_proxy(
7476
self,

pyrogram/methods/bots/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from .answer_web_app_query import AnswerWebAppQuery
2424
from .create_invoice_link import CreateInvoiceLink
2525
from .delete_bot_commands import DeleteBotCommands
26+
from .edit_user_star_subscription import EditUserStarSubscription
2627
from .get_bot_commands import GetBotCommands
2728
from .get_bot_default_privileges import GetBotDefaultPrivileges
2829
from .get_bot_info_description import GetBotInfoDescription
@@ -64,6 +65,7 @@ class Bots(
6465
SetBotCommands,
6566
GetBotCommands,
6667
DeleteBotCommands,
68+
EditUserStarSubscription,
6769
SetBotDefaultPrivileges,
6870
SetBotInfoDescription,
6971
SetBotInfoShortDescription,
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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 EditUserStarSubscription:
26+
async def edit_user_star_subscription(
27+
self: "pyrogram.Client",
28+
user_id: Union[int, str],
29+
telegram_payment_charge_id: str,
30+
is_canceled: bool,
31+
) -> bool:
32+
"""Cancels or re-enables Telegram Star subscription for a user.
33+
34+
.. include:: /_includes/usable-by/bots.rst
35+
36+
Parameters:
37+
user_id (``int`` | ``str``):
38+
Unique identifier (int) or username (str) of the target user.
39+
40+
telegram_payment_charge_id (``str``):
41+
Telegram payment identifier of the subscription.
42+
43+
is_canceled (``bool``):
44+
Pass True to cancel the subscription.
45+
Pass False to allow the user to enable it.
46+
47+
Returns:
48+
``bool``: On success, True is returned.
49+
"""
50+
return await self.invoke(
51+
raw.functions.payments.BotCancelStarsSubscription(
52+
user_id=await self.resolve_peer(user_id),
53+
charge_id=telegram_payment_charge_id,
54+
restore=is_canceled,
55+
)
56+
)

0 commit comments

Comments
 (0)