mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
Merge 8ef7f68bf7 into cb38d6a02b
This commit is contained in:
commit
db55c19c5d
4 changed files with 58 additions and 0 deletions
|
|
@ -657,6 +657,7 @@ def pyrogram_api():
|
||||||
RequestPeerTypeChannel
|
RequestPeerTypeChannel
|
||||||
RequestPeerTypeChat
|
RequestPeerTypeChat
|
||||||
RequestPeerTypeUser
|
RequestPeerTypeUser
|
||||||
|
KeyboardButtonPollType
|
||||||
RequestedChats
|
RequestedChats
|
||||||
RequestedChat
|
RequestedChat
|
||||||
RequestedUser
|
RequestedUser
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ from .reply_keyboard_remove import ReplyKeyboardRemove
|
||||||
from .request_peer_type_channel import RequestPeerTypeChannel
|
from .request_peer_type_channel import RequestPeerTypeChannel
|
||||||
from .request_peer_type_chat import RequestPeerTypeChat
|
from .request_peer_type_chat import RequestPeerTypeChat
|
||||||
from .request_peer_type_user import RequestPeerTypeUser
|
from .request_peer_type_user import RequestPeerTypeUser
|
||||||
|
from .keyboard_button_poll_type import KeyboardButtonPollType
|
||||||
from .requested_chat import RequestedChat
|
from .requested_chat import RequestedChat
|
||||||
from .requested_chats import RequestedChats
|
from .requested_chats import RequestedChats
|
||||||
from .requested_user import RequestedUser
|
from .requested_user import RequestedUser
|
||||||
|
|
@ -73,6 +74,7 @@ __all__ = [
|
||||||
"RequestPeerTypeChannel",
|
"RequestPeerTypeChannel",
|
||||||
"RequestPeerTypeChat",
|
"RequestPeerTypeChat",
|
||||||
"RequestPeerTypeUser",
|
"RequestPeerTypeUser",
|
||||||
|
"KeyboardButtonPollType",
|
||||||
"RequestedChats",
|
"RequestedChats",
|
||||||
"RequestedChat",
|
"RequestedChat",
|
||||||
"RequestedUser",
|
"RequestedUser",
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,9 @@ class KeyboardButton(Object):
|
||||||
If specified, defines the criteria used to request a suitable users.
|
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.
|
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*):
|
web_app (:obj:`~pyrogram.types.WebAppInfo`, *optional*):
|
||||||
If specified, the described `Web App <https://core.telegram.org/bots/webapps>`_ will be launched when the
|
If specified, the described `Web App <https://core.telegram.org/bots/webapps>`_ 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
|
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_location: bool = None,
|
||||||
request_chat: Union["types.RequestPeerTypeChat","types.RequestPeerTypeChannel"] = None,
|
request_chat: Union["types.RequestPeerTypeChat","types.RequestPeerTypeChannel"] = None,
|
||||||
request_user: "types.RequestPeerTypeUser" = None,
|
request_user: "types.RequestPeerTypeUser" = None,
|
||||||
|
request_poll: "types.KeyboardButtonPollType" = None,
|
||||||
web_app: "types.WebAppInfo" = None
|
web_app: "types.WebAppInfo" = None
|
||||||
):
|
):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
@ -70,6 +74,7 @@ class KeyboardButton(Object):
|
||||||
self.request_location = request_location
|
self.request_location = request_location
|
||||||
self.request_chat = request_chat
|
self.request_chat = request_chat
|
||||||
self.request_user = request_user
|
self.request_user = request_user
|
||||||
|
self.request_poll = request_poll
|
||||||
self.web_app = web_app
|
self.web_app = web_app
|
||||||
|
|
||||||
@staticmethod
|
@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):
|
def write(self):
|
||||||
if self.request_contact:
|
if self.request_contact:
|
||||||
return raw.types.KeyboardButtonRequestPhone(text=self.text)
|
return raw.types.KeyboardButtonRequestPhone(text=self.text)
|
||||||
|
|
@ -224,6 +237,11 @@ class KeyboardButton(Object):
|
||||||
username_requested=self.request_user.is_username_requested,
|
username_requested=self.request_user.is_username_requested,
|
||||||
photo_requested=self.request_user.is_photo_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:
|
elif self.web_app:
|
||||||
return raw.types.KeyboardButtonSimpleWebView(text=self.text, url=self.web_app.url)
|
return raw.types.KeyboardButtonSimpleWebView(text=self.text, url=self.web_app.url)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
# Pyrofork - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||||
|
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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
|
||||||
Loading…
Reference in a new issue