diff --git a/compiler/docs/compiler.py b/compiler/docs/compiler.py index 64b3dae9..4d81f8d2 100644 --- a/compiler/docs/compiler.py +++ b/compiler/docs/compiler.py @@ -658,6 +658,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..b2f3769e --- /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