Skip to content
Merged

9.6 #232

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f14cb4b
Add animation, photo, sticker, video in InputPollOption
SpEcHiDe Apr 4, 2026
27ef600
Add send_poll
SpEcHiDe Apr 4, 2026
05b2dcd
Added the field poll_option_id to the class ReplyParameters, allowing…
SpEcHiDe Apr 4, 2026
36b17d1
Added the field reply_to_poll_option_id to the class Message.
SpEcHiDe Apr 4, 2026
477de79
Rename TranslatedText to FormattedText
SpEcHiDe Apr 4, 2026
32d8398
Add unknown_errors
SpEcHiDe Apr 4, 2026
84b2410
send_poll
SpEcHiDe Apr 4, 2026
3d5d1d5
changes
SpEcHiDe Apr 4, 2026
ac04e67
changes
SpEcHiDe Apr 5, 2026
e81334a
changes
SpEcHiDe Apr 5, 2026
25f07a6
changes
SpEcHiDe Apr 5, 2026
1374584
changes
SpEcHiDe Apr 5, 2026
07ee41f
changes
SpEcHiDe Apr 5, 2026
788f111
KeyboardButtonRequestManagedBot
SpEcHiDe Apr 5, 2026
e09576e
Added the field can_manage_bots to the class User.
SpEcHiDe Apr 5, 2026
f0bb1a5
Added updates about the creation of managed bots and the change of th…
SpEcHiDe Apr 5, 2026
b584ea4
docs
SpEcHiDe Apr 5, 2026
98e88be
changes
SpEcHiDe Apr 5, 2026
8b9f22c
Add note
SpEcHiDe Apr 5, 2026
0b208ae
changes
SpEcHiDe Apr 6, 2026
6110a39
docs
SpEcHiDe Apr 6, 2026
54c70f2
bound
SpEcHiDe Apr 6, 2026
aed56c2
add_poll_option, delete_poll_option
SpEcHiDe Apr 6, 2026
cf24853
docs
SpEcHiDe Apr 6, 2026
a7c63d7
Add tone in translate_message_text and translate_text
SpEcHiDe Apr 6, 2026
b1f1e8d
Add undocumented parameters in send_poll and reply_poll
SpEcHiDe Apr 6, 2026
e0e4d7b
Add unknown_errors
SpEcHiDe Apr 6, 2026
f04cfde
changes
SpEcHiDe Apr 6, 2026
f8ffa17
docs
SpEcHiDe Apr 6, 2026
408023c
add missing entities
SpEcHiDe Apr 6, 2026
643b3eb
Add unread_poll_vote_count in ForumTopic and Dialog
SpEcHiDe Apr 6, 2026
0416531
Add uses_unofficial_app to Chat
SpEcHiDe Apr 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion compiler/docs/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ def get_title_list(s: str) -> list:
send_checklist
edit_message_checklist
mark_checklist_tasks_as_done
add_poll_option
delete_poll_option
""",
chats="""
Chats
Expand Down Expand Up @@ -635,6 +637,8 @@ def get_title_list(s: str) -> list:
UpgradedGift
WebAppData
MessageAutoDeleteTimerChanged
PollOptionAdded
PollOptionDeleted
ChatBoostAdded
ChatBackground
Game
Expand All @@ -656,7 +660,7 @@ def get_title_list(s: str) -> list:
ReactionTypeCustomEmoji
ReactionTypePaid
Thumbnail
TranslatedText
FormattedText
StrippedThumbnail
SponsoredMessage
Sticker
Expand All @@ -668,6 +672,8 @@ def get_title_list(s: str) -> list:
ChatOwnerChanged
ChatHasProtectedContentToggled
ChatHasProtectedContentDisableRequested
ManagedBotCreated
ManagedBotUpdated
""",
chat_topics="""
Chat Forum Topics
Expand Down Expand Up @@ -706,6 +712,7 @@ def get_title_list(s: str) -> list:
KeyboardButtonPollTypeQuiz
KeyboardButtonRequestChat
KeyboardButtonRequestUsers
KeyboardButtonRequestManagedBot
ReplyKeyboardMarkup
ReplyKeyboardRemove
LoginUrl
Expand Down
13 changes: 13 additions & 0 deletions compiler/errors/source/400_BAD_REQUEST.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ ADMIN_RANK_EMOJI_NOT_ALLOWED An admin rank cannot contain emojis.
ADMIN_RANK_INVALID The specified admin rank is invalid.
ADMIN_RIGHTS_EMPTY The chatAdminRights constructor passed in keyboardButtonRequestPeer.peer_type.user_admin_rights has no rights set (i.e. flags is 0).
AD_EXPIRED The ad has expired (too old or not found).
AI_COMPOSE_TASK_MISSING The text composition style is missing.
ALBUM_PHOTOS_TOO_MANY You have uploaded too many profile photos, delete some before retrying.
ANSWER_X_MEDIA_TYPE_INVALID The option media type at index {value} is invalid.
ANONYMOUS_OPEN_INVALID allow_adding_options is not supported for anonymous polls and quizzes.
API_ID_INVALID API ID invalid.
API_ID_PUBLISHED_FLOOD This API id was published somewhere, you can't use it now.
ARTICLE_TITLE_EMPTY The title of the article is empty.
ATTACH_MEDIA_EMPTY The attached media is empty.
ATTACH_MEDIA_TYPE_INVALID The attached_media is invalid.
AUDIO_CONTENT_URL_EMPTY The remote URL specified in the content field is empty.
AUDIO_TITLE_EMPTY An empty audio title was provided.
AUTH_BYTES_INVALID The provided authorization is invalid.
Expand All @@ -26,6 +31,7 @@ BALANCE_TOO_LOW The transaction cannot be completed because the current [Telegra
BANK_CARD_NUMBER_INVALID The specified card number is invalid.
BANNED_RIGHTS_INVALID You provided some invalid flags in the banned rights.
BASE_PORT_LOC_INVALID The base port location is invalid
BIRTHDAY_ALREADY The user has already entered a birthday.
BIRTHDAY_INVALID An invalid age was specified, must be between 0 and 150 years.
BOOSTS_EMPTY No boost slots were specified.
BOOSTS_REQUIRED The specified channel must first be [boosted by its users](https://core.telegram.org/api/boost) in order to perform this action.
Expand Down Expand Up @@ -154,6 +160,7 @@ DATA_JSON_INVALID The provided JSON data is invalid.
DATA_TOO_LONG Data too long.
DATE_EMPTY Date empty.
DC_ID_INVALID The provided DC ID is invalid.
DELETE_ANSWER_FORBIDDEN You cannot delete the specified option in this poll.
DH_G_A_INVALID g_a invalid.
DOCUMENT_INVALID The specified document is invalid.
EFFECT_ID_INVALID The specified effect ID is invalid.
Expand Down Expand Up @@ -262,6 +269,7 @@ INLINE_RESULT_EXPIRED The inline query expired.
INPUT_CHATLIST_INVALID The specified folder is invalid.
INPUT_CONSTRUCTOR_INVALID The specified TL constructor is invalid.
INPUT_FETCH_ERROR An error occurred while parsing the provided TL constructor.
INPUT_FETCH_ERROR_X An error occurred while parsing the provided TL {value} constructor.
INPUT_FETCH_FAIL An error occurred while parsing the provided TL constructor.
INPUT_FILE_INVALID The specified [InputFile](https://core.telegram.org/type/InputFile) is invalid.
INPUT_FILTER_INVALID The specified filter is invalid.
Expand Down Expand Up @@ -294,6 +302,8 @@ LASTNAME_INVALID The last name is invalid.
LIMIT_INVALID The provided limit is invalid.
LINK_NOT_MODIFIED Discussion link not modified.
LOCATION_INVALID The provided location is invalid.
MANAGER_INVALID The provided bot manager is invalid. Bot Management Mode should be enabled for the bot in the @BotFather Mini App.
MANAGER_PERMISSION_MISSING The bot manager permission is missing. Bot Management Mode should be enabled for the bot in the @BotFather Mini App.
MAX_DATE_INVALID The specified maximum date is invalid.
MAX_ID_INVALID The provided max ID is invalid.
MAX_QTS_INVALID The specified max_qts is invalid.
Expand Down Expand Up @@ -487,6 +497,8 @@ SLOWMODE_MULTI_MSGS_DISABLED Slowmode is enabled, you cannot forward multiple me
SLUG_INVALID The specified invoice slug is invalid.
SMSJOB_ID_INVALID The specified job ID is invalid.
SMS_CODE_CREATE_FAILED An error occurred while creating the SMS code.
SOLUTION_MEDIA_EMPTY The solution_media is empty.
SOLUTION_MEDIA_TYPE_INVALID The solution_media is invalid.
SRP_A_INVALID The specified inputCheckPasswordSRP.A value is invalid.
SRP_ID_INVALID Invalid SRP ID provided.
SRP_PASSWORD_CHANGED Password has changed.
Expand Down Expand Up @@ -618,6 +630,7 @@ USERNAME_NOT_MODIFIED The username was not modified.
USERNAME_NOT_OCCUPIED The provided username is not occupied.
USERNAME_OCCUPIED The provided username is already occupied.
USERNAME_PURCHASE_AVAILABLE The specified username can be purchased on https://fragment.com.
USERNAME_SUFFIX_MISSING Bot username must end in `bot`.
USERPIC_UPLOAD_REQUIRED You must have a profile picture to publish your geolocation.
USERS_TOO_FEW Not enough users (to create a chat, for example).
USERS_TOO_MUCH The maximum number of users has been exceeded (to create a chat, for example).
Expand Down
1 change: 1 addition & 0 deletions compiler/errors/source/406_NOT_ACCEPTABLE.tsv
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
id message
AICOMPOSE_ERROR_OCCURED The composeTextWithAi method encountered an error.
ALLOW_PAYMENT_REQUIRED This peer only accepts [paid messages](https://core.telegram.org/api/paid-messages): this error is only emitted for older layers without paid messages support, so the client must be updated in order to use paid messages. .
API_GIFT_RESTRICTED_UPDATE_APP Please update the app to access the gift API.
AUTH_KEY_DUPLICATED Concurrent usage of the current session from multiple connections was detected, the current session was invalidated by the server for security reasons!
Expand Down
20 changes: 20 additions & 0 deletions docs/source/releases/changes-in-this-fork.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ Breaking Changes in this Fork
Changes in this Fork
=====================

+------------------------+
| Scheme layer used: 224 |
+------------------------+

- Added the methods :meth:`~pyrogram.Client.add_poll_option` and :meth:`~pyrogram.Client.delete_poll_option`.
- Added the field ``can_manage_bots`` to the class :obj:`~pyrogram.types.User`.
- Added the class :obj:`~pyrogram.types.KeyboardButtonRequestManagedBot` and the field ``request_managed_bot`` to the class :obj:`~pyrogram.types.KeyboardButton`.
- Added the class :obj:`~pyrogram.types.ManagedBotCreated` and the field ``managed_bot_created`` to the class :obj:`~pyrogram.types.Message`.
- Added updates about the creation of managed bots and the change of their token, represented by the class :obj:`~pyrogram.handlers.ManagedBotUpdateHandler`.
- Added support for quizzes with multiple correct answers.
- Added the fields ``correct_option_ids``, ``allows_revoting``, ``description`` to the class :obj:`~pyrogram.types.Poll`.
- Added the parameters ``correct_option_ids``, ``allows_multiple_answers``, ``allows_revoting``, ``shuffle_options``, ``allow_adding_options``, ``hide_results_until_closes``, ``description`` to the method :meth:`~pyrogram.Client.send_poll`.
- Added the field ``option_persistent_ids`` to the class :obj:`~pyrogram.types.PollAnswer`.
- Added the fields ``persistent_id``, ``addition_date``, ``added_by_user`` and ``added_by_chat`` to the class :obj:`~pyrogram.types.PollOption`.
- Added the classes :obj:`~pyrogram.types.PollOptionAdded` and :obj:`~pyrogram.types.PollOptionDeleted` and the fields ``poll_option_added``, ``poll_option_deleted`` to the class :obj:`~pyrogram.types.Message`.
- Added the field ``poll_option_id`` to the class :obj:`~pyrogram.types.ReplyParameters`, allowing to reply to a specific poll option.
- Added the field ``reply_to_poll_option_id`` to the class :obj:`~pyrogram.types.Message`.
- Added the method :meth:`~pyrogram.Client.send_message_draft` (contributed by @sudo-py-dev in `#231 <https://github.com/TelegramPlayground/pyrogram/pull/231>`__).
- View `new and changed <https://telegramplayground.github.io/TG-APIs/TL/diff/tdlib.html?from=222&to=223>`__ `raw API methods <https://telegramplayground.github.io/TG-APIs/TL/diff/tdesktop.html?from=222&to=223>`__.

+------------------------+
| Scheme layer used: 223 |
+------------------------+
Expand Down
12 changes: 11 additions & 1 deletion pyrogram/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
ChatJoinRequestHandler,


ManagedBotUpdateHandler,
DeletedMessagesHandler,
UserStatusHandler,
StoryHandler,
Expand All @@ -66,6 +67,7 @@
UpdateBusinessBotCallbackQuery,
UpdateBotBusinessConnect,
UpdateBotPurchasedPaidMedia,
UpdateManagedBot,
)

log = logging.getLogger(__name__)
Expand All @@ -90,6 +92,7 @@ class Dispatcher:
NEW_STORY_UPDATES = (UpdateStory,)
BOT_BUSINESS_CONNECT_UPDATES = (UpdateBotBusinessConnect,)
PURCHASED_PAID_MEDIA_UPDATES = (UpdateBotPurchasedPaidMedia,)
MANAGED_BOT_UPDATES = (UpdateManagedBot,)

def __init__(self, client: "pyrogram.Client"):
self.client = client
Expand Down Expand Up @@ -151,7 +154,7 @@ async def inline_query_parser(update, users, chats):

async def poll_parser(update, users, chats):
return (
pyrogram.types.Poll._parse_update(
await pyrogram.types.Poll._parse_update(
self.client, update, users, chats
),
PollHandler
Expand Down Expand Up @@ -233,6 +236,12 @@ async def purchased_paid_media_parser(update, users, chats):
PurchasedPaidMediaHandler
)

async def managed_bot_update_parser(update, users, chats):
return (
pyrogram.types.ManagedBotUpdated._parse(self.client, update, users),
ManagedBotUpdateHandler
)

self.update_parsers = {
Dispatcher.NEW_MESSAGE_UPDATES: message_parser,
Dispatcher.EDIT_MESSAGE_UPDATES: edited_message_parser,
Expand All @@ -252,6 +261,7 @@ async def purchased_paid_media_parser(update, users, chats):
Dispatcher.NEW_STORY_UPDATES: story_parser,
Dispatcher.BOT_BUSINESS_CONNECT_UPDATES: bot_business_connect_parser,
Dispatcher.PURCHASED_PAID_MEDIA_UPDATES: purchased_paid_media_parser,
Dispatcher.MANAGED_BOT_UPDATES: managed_bot_update_parser,
}

self.update_parsers = {key: value for key_tuple, value in self.update_parsers.items() for key in key_tuple}
Expand Down
9 changes: 9 additions & 0 deletions pyrogram/enums/message_entity_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,14 @@ class MessageEntityType(AutoName):
DATE_TIME = raw.types.MessageEntityFormattedDate
"for formatted date and time (see ``unix_time`` and ``date_time_format``)"

DIFF_TYPE_INSERT = raw.types.MessageEntityDiffInsert
"Represents a change of a text: Addition of some text"

DIFF_TYPE_REPLACE = raw.types.MessageEntityDiffReplace
"Represents a change of a text: Change of some text"

DIFF_TYPE_DELETE = raw.types.MessageEntityDiffDelete
"Represents a change of a text: Removal of some text"

UNKNOWN = raw.types.MessageEntityUnknown
"Unknown message entity type"
9 changes: 9 additions & 0 deletions pyrogram/enums/message_service_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,14 @@ class MessageServiceType(AutoName):
CHAT_HAS_PROTECTED_CONTENT_DISABLE_REQUESTED = auto()
"Chat has_protected_content setting was requested to be disabled"

MANAGED_BOT_CREATED = auto()
"A bot managed by another bot was created by the user"

POLL_OPTION_ADDED = auto()
"An option was added to a poll"

POLL_OPTION_DELETED = auto()
"A message with information about a deleted poll option"

UNKNOWN = auto()
"This service message is unsupported by the current version of Pyrogram"
1 change: 1 addition & 0 deletions pyrogram/handlers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@
from .purchased_paid_media_handler import PurchasedPaidMediaHandler
from .shipping_query_handler import ShippingQueryHandler
from .story_handler import StoryHandler
from .managed_bot_update_handler import ManagedBotUpdateHandler
62 changes: 62 additions & 0 deletions pyrogram/handlers/managed_bot_update_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

from typing import Any, Callable

import pyrogram
from pyrogram.filters import Filter
from .handler import Handler

CallbackFunc: Callable = Callable[
[
"pyrogram.Client",
pyrogram.types.ManagedBotUpdated
],
Any
]


class ManagedBotUpdateHandler(Handler):
"""The ManagedBotUpdate handler class.
Used to handle new managed bot creation updates.

It is intended to be used with :meth:`~pyrogram.Client.add_handler`.

For a nicer way to register this handler, have a look at the
:meth:`~pyrogram.Client.on_managed_bot` decorator.

Parameters:
callback (``Callable``):
Pass a function that will be called when a new ManagedBotUpdated event arrives. It takes
*(client, managed_bot)* as positional arguments (look at the section below for a detailed
description).

filters (:obj:`Filters`):
Pass one or more filters to allow only a subset of updates to be passed in your callback function.

Other parameters:
client (:obj:`~pyrogram.Client`):
The Client itself, useful when you want to call other API methods inside the handler.

managed_bot (:obj:`~pyrogram.types.ManagedBotUpdated`):
A new bot was created to be managed by the bot or token of a bot was changed.

"""

def __init__(self, callback: CallbackFunc, filters: Filter = None):
super().__init__(callback, filters)
2 changes: 2 additions & 0 deletions pyrogram/methods/decorators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from .on_pre_checkout_query import OnPreCheckoutQuery
from .on_shipping_query import OnShippingQuery
from .on_story import OnStory
from .on_managed_bot import OnManagedBot


class Decorators(
Expand All @@ -59,6 +60,7 @@ class Decorators(
OnDisconnect,
OnUserStatus,
OnStory,
OnManagedBot,
OnRawUpdate,
):
pass
64 changes: 64 additions & 0 deletions pyrogram/methods/decorators/on_managed_bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

from typing import Callable

import pyrogram
from pyrogram.filters import Filter


class OnManagedBot:
def on_managed_bot(
self=None,
filters=None,
group: int = 0
) -> Callable:
"""Decorator for handling new managed bot creation updates.

This does the same thing as :meth:`~pyrogram.Client.add_handler` using the
:obj:`~pyrogram.handlers.ManagedBotUpdateHandler`.

.. include:: /_includes/usable-by/bots.rst

Parameters:
filters (:obj:`~pyrogram.filters`, *optional*):
Pass one or more filters to allow only a subset of callback queries to be passed
in your function.

group (``int``, *optional*):
The group identifier, defaults to 0.

"""

def decorator(func: Callable) -> Callable:
if isinstance(self, pyrogram.Client):
self.add_handler(pyrogram.handlers.ManagedBotUpdateHandler(func, filters), group)
elif isinstance(self, Filter) or self is None:
if not hasattr(func, "handlers"):
func.handlers = []

func.handlers.append(
(
pyrogram.handlers.ManagedBotUpdateHandler(func, self),
group if filters is None else filters
)
)

return func

return decorator
4 changes: 4 additions & 0 deletions pyrogram/methods/messages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
from .send_checklist import SendChecklist
from .edit_message_checklist import EditMessageChecklist
from .mark_checklist_tasks_as_done import MarkChecklistTasksAsDone
from .add_poll_option import AddPollOption
from .delete_poll_option import DeletePollOption

class Messages(
CopyMediaGroup,
Expand Down Expand Up @@ -140,5 +142,7 @@ class Messages(
SendChecklist,
EditMessageChecklist,
MarkChecklistTasksAsDone,
AddPollOption,
DeletePollOption
):
pass
Loading