mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
Pyrofork: Add request_channel parameters to KeyboardButton class
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
9299b9bd7d
commit
d3ef8fb24a
4 changed files with 68 additions and 0 deletions
|
|
@ -459,6 +459,7 @@ def pyrogram_api():
|
|||
ReplyKeyboardRemove
|
||||
InlineKeyboardMarkup
|
||||
InlineKeyboardButton
|
||||
RequestPeerTypeChannel
|
||||
RequestPeerTypeChat
|
||||
RequestPeerTypeUser
|
||||
LoginUrl
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ from .menu_button_default import MenuButtonDefault
|
|||
from .menu_button_web_app import MenuButtonWebApp
|
||||
from .reply_keyboard_markup import ReplyKeyboardMarkup
|
||||
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 .sent_web_app_message import SentWebAppMessage
|
||||
|
|
@ -55,6 +56,7 @@ __all__ = [
|
|||
"KeyboardButton",
|
||||
"ReplyKeyboardMarkup",
|
||||
"ReplyKeyboardRemove",
|
||||
"RequestPeerTypeChannel",
|
||||
"RequestPeerTypeChat",
|
||||
"RequestPeerTypeUser",
|
||||
"LoginUrl",
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ class KeyboardButton(Object):
|
|||
If True, the user's current location will be sent when the button is pressed.
|
||||
Available in private chats only.
|
||||
|
||||
request_channel ("obj:`~pyrogram.types.RequestPeerTypeChannel`, *optional*):
|
||||
If specified, defines the criteria used to request a suitable channels.
|
||||
The identifier of the selected channels will be shared with the bot when the corresponding button is pressed.
|
||||
|
||||
request_chat ("obj:`~pyrogram.types.RequestPeerTypeChat`, *optional*):
|
||||
If specified, defines the criteria used to request a suitable chats.
|
||||
The identifier of the selected chats will be shared with the bot when the corresponding button is pressed.
|
||||
|
|
@ -58,6 +62,7 @@ class KeyboardButton(Object):
|
|||
text: str,
|
||||
request_contact: bool = None,
|
||||
request_location: bool = None,
|
||||
request_channel: "types.RequestPeerTypeChannel" = None,
|
||||
request_chat: "types.RequestPeerTypeChat" = None,
|
||||
request_user: "types.RequestPeerTypeUser" = None,
|
||||
web_app: "types.WebAppInfo" = None
|
||||
|
|
@ -67,6 +72,7 @@ class KeyboardButton(Object):
|
|||
self.text = str(text)
|
||||
self.request_contact = request_contact
|
||||
self.request_location = request_location
|
||||
self.request_channel = request_channel
|
||||
self.request_chat = request_chat
|
||||
self.request_user = request_user
|
||||
self.web_app = web_app
|
||||
|
|
@ -96,6 +102,15 @@ class KeyboardButton(Object):
|
|||
)
|
||||
)
|
||||
|
||||
if isinstance(b, raw.types.RequestPeerTypeBroadcast):
|
||||
return KeyboardButton(
|
||||
text=b.text,
|
||||
request_chat=types.RequestPeerTypeChannel(
|
||||
is_creator=b.creator,
|
||||
is_username=b.has_username
|
||||
)
|
||||
)
|
||||
|
||||
if isinstance(b, raw.types.RequestPeerTypeChat):
|
||||
return KeyboardButton(
|
||||
text=b.text,
|
||||
|
|
@ -121,6 +136,15 @@ class KeyboardButton(Object):
|
|||
return raw.types.KeyboardButtonRequestPhone(text=self.text)
|
||||
elif self.request_location:
|
||||
return raw.types.KeyboardButtonRequestGeoLocation(text=self.text)
|
||||
elif self.request_channel:
|
||||
return raw.types.KeyboardButtonRequestPeer(
|
||||
text=self.text,
|
||||
button_id=0,
|
||||
peer_type=raw.types.RequestPeerTypeBroadcast(
|
||||
creator=self.request_broadcast.is_creator,
|
||||
has_username=self.request_broadcast.is_username
|
||||
)
|
||||
)
|
||||
elif self.request_chat:
|
||||
return raw.types.KeyboardButtonRequestPeer(
|
||||
text=self.text,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
# Pyrofork - Telegram MTProto API Client Library for Python
|
||||
# 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 RequestPeerTypeChannel(Object):
|
||||
"""Object used to request clients to send a channel identifier.
|
||||
|
||||
Parameters:
|
||||
is_creator (``bool``, *optional*):
|
||||
If True, show only Channel which user is the owner.
|
||||
|
||||
is_username (``bool``, *optional*):
|
||||
If True, show only Channel which has username.
|
||||
""" # TODO user_admin_rights, bot_admin_rights
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
is_creator: bool=None,
|
||||
is_username: bool=None
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
self.is_creator = is_creator
|
||||
self.is_username = is_username
|
||||
Loading…
Reference in a new issue