From 6ecc504b62d0458cf009c2349b02f92f20a28933 Mon Sep 17 00:00:00 2001 From: store-x Date: Fri, 26 Sep 2025 09:12:49 +0000 Subject: [PATCH 1/4] Add request_poll parameters to KeyboardButton class --- compiler/docs/compiler.py | 1 + pyrogram/types/bots_and_keyboards/__init__.py | 2 + .../bots_and_keyboards/keyboard_button.py | 18 +++++++++ .../keyboard_button_poll_type.py‎ | 37 +++++++++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py‎ diff --git a/compiler/docs/compiler.py b/compiler/docs/compiler.py index f262a6b3..e1e19877 100644 --- a/compiler/docs/compiler.py +++ b/compiler/docs/compiler.py @@ -657,6 +657,7 @@ def pyrogram_api(): RequestPeerTypeChannel RequestPeerTypeChat RequestPeerTypeUser + KeyboardButtonPollType RequestedChats RequestedChat RequestedUser diff --git a/pyrogram/types/bots_and_keyboards/__init__.py b/pyrogram/types/bots_and_keyboards/__init__.py index c8228b58..495ae082 100644 --- a/pyrogram/types/bots_and_keyboards/__init__.py +++ b/pyrogram/types/bots_and_keyboards/__init__.py @@ -49,6 +49,7 @@ from .reply_keyboard_remove import ReplyKeyboardRemove from .request_peer_type_channel import RequestPeerTypeChannel from .request_peer_type_chat import RequestPeerTypeChat from .request_peer_type_user import RequestPeerTypeUser +from .keyboard_button_poll_type import KeyboardButtonPollType from .requested_chat import RequestedChat from .requested_chats import RequestedChats from .requested_user import RequestedUser @@ -73,6 +74,7 @@ __all__ = [ "RequestPeerTypeChannel", "RequestPeerTypeChat", "RequestPeerTypeUser", + "KeyboardButtonPollType", "RequestedChats", "RequestedChat", "RequestedUser", diff --git a/pyrogram/types/bots_and_keyboards/keyboard_button.py b/pyrogram/types/bots_and_keyboards/keyboard_button.py index 82c30b87..bf180a0b 100644 --- a/pyrogram/types/bots_and_keyboards/keyboard_button.py +++ b/pyrogram/types/bots_and_keyboards/keyboard_button.py @@ -47,6 +47,9 @@ class KeyboardButton(Object): If specified, defines the criteria used to request a suitable users. The identifier of the selected users will be shared with the bot when the corresponding button is pressed. + request_poll (:obj:`~pyrogram.types.KeyboardButtonPollType`, *optional*): + If specified, the poll be sent when the button is pressed. + web_app (:obj:`~pyrogram.types.WebAppInfo`, *optional*): If specified, the described `Web App `_ will be launched when the button is pressed. The Web App will be able to send a “web_app_data” service message. Available in private @@ -61,6 +64,7 @@ class KeyboardButton(Object): request_location: bool = None, request_chat: Union["types.RequestPeerTypeChat","types.RequestPeerTypeChannel"] = None, request_user: "types.RequestPeerTypeUser" = None, + request_poll: "types.KeyboardButtonPollType" = None, web_app: "types.WebAppInfo" = None ): super().__init__() @@ -70,6 +74,7 @@ class KeyboardButton(Object): self.request_location = request_location self.request_chat = request_chat self.request_user = request_user + self.request_poll = request_poll self.web_app = web_app @staticmethod @@ -137,6 +142,14 @@ class KeyboardButton(Object): ) ) + if isinstance(b, raw.types.KeyboardButtonRequestPoll): + return KeyboardButton( + text=b.text, + request_poll=types.KeyboardButtonPollType( + is_quiz=b.quiz + ) + ) + def write(self): if self.request_contact: return raw.types.KeyboardButtonRequestPhone(text=self.text) @@ -224,6 +237,11 @@ class KeyboardButton(Object): username_requested=self.request_user.is_username_requested, photo_requested=self.request_user.is_photo_requested ) + elif self.request_poll: + return raw.types.KeyboardButtonRequestPoll( + text=self.text, + quiz=self.request_poll.is_quiz + ) elif self.web_app: return raw.types.KeyboardButtonSimpleWebView(text=self.text, url=self.web_app.url) else: diff --git a/pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py‎ b/pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py‎ new file mode 100644 index 00000000..694fd43e --- /dev/null +++ b/pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py‎ @@ -0,0 +1,37 @@ +# Pyrofork - Telegram MTProto API Client Library for Python +# Copyright (C) 2017-present Dan +# Copyright (C) 2022-present Mayuri-Chan +# +# This file is part of Pyrofork. +# +# Pyrofork 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. +# +# Pyrofork 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 Pyrofork. If not, see . + +from ..object import Object + + +class KeyboardButtonPollType(Object): + """Contains information about a poll type. + + Parameters: + is_quiz (``bool``): + If True, the requested poll will be sent as quiz. + """ + + def __init__( + self, *, + is_quiz: bool = None + ): + super().__init__() + + self.is_quiz = is_quiz \ No newline at end of file From f43c524773b128f3beb42dcf6f3608f9bd6b7abb Mon Sep 17 00:00:00 2001 From: store-x Date: Fri, 26 Sep 2025 09:37:40 +0000 Subject: [PATCH 2/4] correct typo in filename --- ...{keyboard_button_poll_type.py‎ => keyboard_button_poll_type.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pyrogram/types/bots_and_keyboards/{keyboard_button_poll_type.py‎ => keyboard_button_poll_type.py} (100%) diff --git a/pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py‎ b/pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py similarity index 100% rename from pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py‎ rename to pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py From e14743e4e8b82a3965f3bc3f2dac7c50c48353c0 Mon Sep 17 00:00:00 2001 From: store-x Date: Mon, 8 Dec 2025 20:28:33 +0530 Subject: [PATCH 3/4] Fix newline issue at end of file --- pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py b/pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py index 694fd43e..076d4e48 100644 --- a/pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py +++ b/pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py @@ -34,4 +34,5 @@ class KeyboardButtonPollType(Object): ): super().__init__() - self.is_quiz = is_quiz \ No newline at end of file + self.is_quiz = is_quiz + From 8ef7f68bf75382ad8473825237f8398b25e7f667 Mon Sep 17 00:00:00 2001 From: store-x Date: Mon, 8 Dec 2025 20:41:20 +0530 Subject: [PATCH 4/4] remove trailing whitespace --- pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py b/pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py index 076d4e48..b2f3769e 100644 --- a/pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py +++ b/pyrogram/types/bots_and_keyboards/keyboard_button_poll_type.py @@ -35,4 +35,3 @@ class KeyboardButtonPollType(Object): super().__init__() self.is_quiz = is_quiz -