mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Refactor bot keyboard types
This commit is contained in:
parent
3f643242b1
commit
a683e3e917
@ -16,11 +16,11 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from pyrogram.api.core import Object
|
|
||||||
from pyrogram.api.types import ReplyKeyboardForceReply
|
from pyrogram.api.types import ReplyKeyboardForceReply
|
||||||
|
from ..pyrogram_type import PyrogramType
|
||||||
|
|
||||||
|
|
||||||
class ForceReply(Object):
|
class ForceReply(PyrogramType):
|
||||||
"""Upon receiving a message with this object, Telegram clients will display a reply interface to the user
|
"""Upon receiving a message with this object, Telegram clients will display a reply interface to the user
|
||||||
(act as if the user has selected the bot's message and tapped 'Reply').
|
(act as if the user has selected the bot's message and tapped 'Reply').
|
||||||
This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to
|
This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to
|
||||||
@ -33,9 +33,9 @@ class ForceReply(Object):
|
|||||||
2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
|
2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ID = 0xb0700018
|
|
||||||
|
|
||||||
def __init__(self, selective: bool = None):
|
def __init__(self, selective: bool = None):
|
||||||
|
super().__init__(None, None)
|
||||||
|
|
||||||
self.selective = selective
|
self.selective = selective
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -16,15 +16,14 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from pyrogram.api.core import Object
|
|
||||||
|
|
||||||
from pyrogram.api.types import (
|
from pyrogram.api.types import (
|
||||||
KeyboardButtonUrl, KeyboardButtonCallback,
|
KeyboardButtonUrl, KeyboardButtonCallback,
|
||||||
KeyboardButtonSwitchInline
|
KeyboardButtonSwitchInline
|
||||||
)
|
)
|
||||||
|
from ..pyrogram_type import PyrogramType
|
||||||
|
|
||||||
|
|
||||||
class InlineKeyboardButton(Object):
|
class InlineKeyboardButton(PyrogramType):
|
||||||
"""This object represents one button of an inline keyboard. You must use exactly one of the optional fields.
|
"""This object represents one button of an inline keyboard. You must use exactly one of the optional fields.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -54,18 +53,10 @@ class InlineKeyboardButton(Object):
|
|||||||
|
|
||||||
# TODO: Add callback_game and pay fields
|
# TODO: Add callback_game and pay fields
|
||||||
|
|
||||||
ID = 0xb0700019
|
def __init__(self, text: str, callback_data: bytes = None, url: str = None,
|
||||||
|
switch_inline_query: str = None, switch_inline_query_current_chat: str = None):
|
||||||
|
super().__init__(None, None)
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
text: str,
|
|
||||||
callback_data: bytes = None,
|
|
||||||
url: str = None,
|
|
||||||
switch_inline_query: str = None,
|
|
||||||
switch_inline_query_current_chat: str = None,
|
|
||||||
# callback_game=None,
|
|
||||||
# pay: bool = None
|
|
||||||
):
|
|
||||||
self.text = text
|
self.text = text
|
||||||
self.url = url
|
self.url = url
|
||||||
self.callback_data = callback_data
|
self.callback_data = callback_data
|
||||||
|
@ -16,13 +16,12 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from pyrogram.api.core import Object
|
|
||||||
|
|
||||||
from pyrogram.api.types import ReplyInlineMarkup, KeyboardButtonRow
|
from pyrogram.api.types import ReplyInlineMarkup, KeyboardButtonRow
|
||||||
from . import InlineKeyboardButton
|
from . import InlineKeyboardButton
|
||||||
|
from ..pyrogram_type import PyrogramType
|
||||||
|
|
||||||
|
|
||||||
class InlineKeyboardMarkup(Object):
|
class InlineKeyboardMarkup(PyrogramType):
|
||||||
"""This object represents an inline keyboard that appears right next to the message it belongs to.
|
"""This object represents an inline keyboard that appears right next to the message it belongs to.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -30,9 +29,9 @@ class InlineKeyboardMarkup(Object):
|
|||||||
List of button rows, each represented by a List of InlineKeyboardButton objects.
|
List of button rows, each represented by a List of InlineKeyboardButton objects.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ID = 0xb0700020
|
|
||||||
|
|
||||||
def __init__(self, inline_keyboard: list):
|
def __init__(self, inline_keyboard: list):
|
||||||
|
super().__init__(None, None)
|
||||||
|
|
||||||
self.inline_keyboard = inline_keyboard
|
self.inline_keyboard = inline_keyboard
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -16,13 +16,12 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from pyrogram.api.core import Object
|
|
||||||
|
|
||||||
from pyrogram.api.types import KeyboardButton as RawKeyboardButton
|
from pyrogram.api.types import KeyboardButton as RawKeyboardButton
|
||||||
from pyrogram.api.types import KeyboardButtonRequestPhone, KeyboardButtonRequestGeoLocation
|
from pyrogram.api.types import KeyboardButtonRequestPhone, KeyboardButtonRequestGeoLocation
|
||||||
|
from ..pyrogram_type import PyrogramType
|
||||||
|
|
||||||
|
|
||||||
class KeyboardButton(Object):
|
class KeyboardButton(PyrogramType):
|
||||||
"""This object represents one button of the reply keyboard.
|
"""This object represents one button of the reply keyboard.
|
||||||
For simple text buttons String can be used instead of this object to specify text of the button.
|
For simple text buttons String can be used instead of this object to specify text of the button.
|
||||||
Optional fields are mutually exclusive.
|
Optional fields are mutually exclusive.
|
||||||
@ -41,9 +40,9 @@ class KeyboardButton(Object):
|
|||||||
Available in private chats only.
|
Available in private chats only.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ID = 0xb0700021
|
|
||||||
|
|
||||||
def __init__(self, text: str, request_contact: bool = None, request_location: bool = None):
|
def __init__(self, text: str, request_contact: bool = None, request_location: bool = None):
|
||||||
|
super().__init__(None, None)
|
||||||
|
|
||||||
self.text = text
|
self.text = text
|
||||||
self.request_contact = request_contact
|
self.request_contact = request_contact
|
||||||
self.request_location = request_location
|
self.request_location = request_location
|
||||||
|
@ -16,15 +16,13 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from pyrogram.api.core import Object
|
|
||||||
|
|
||||||
from pyrogram.api.types import KeyboardButtonRow
|
from pyrogram.api.types import KeyboardButtonRow
|
||||||
from pyrogram.api.types import ReplyKeyboardMarkup as RawReplyKeyboardMarkup
|
from pyrogram.api.types import ReplyKeyboardMarkup as RawReplyKeyboardMarkup
|
||||||
|
|
||||||
from . import KeyboardButton
|
from . import KeyboardButton
|
||||||
|
from ..pyrogram_type import PyrogramType
|
||||||
|
|
||||||
|
|
||||||
class ReplyKeyboardMarkup(Object):
|
class ReplyKeyboardMarkup(PyrogramType):
|
||||||
"""This object represents a custom keyboard with reply options.
|
"""This object represents a custom keyboard with reply options.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -49,15 +47,10 @@ class ReplyKeyboardMarkup(Object):
|
|||||||
select the new language. Other users in the group don't see the keyboard.
|
select the new language. Other users in the group don't see the keyboard.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ID = 0xb0700022
|
def __init__(self, keyboard: list, resize_keyboard: bool = None, one_time_keyboard: bool = None,
|
||||||
|
selective: bool = None):
|
||||||
|
super().__init__(None, None)
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
keyboard: list,
|
|
||||||
resize_keyboard: bool = None,
|
|
||||||
one_time_keyboard: bool = None,
|
|
||||||
selective: bool = None
|
|
||||||
):
|
|
||||||
self.keyboard = keyboard
|
self.keyboard = keyboard
|
||||||
self.resize_keyboard = resize_keyboard
|
self.resize_keyboard = resize_keyboard
|
||||||
self.one_time_keyboard = one_time_keyboard
|
self.one_time_keyboard = one_time_keyboard
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from pyrogram.api.core import Object
|
|
||||||
from pyrogram.api.types import ReplyKeyboardHide
|
from pyrogram.api.types import ReplyKeyboardHide
|
||||||
|
from ..pyrogram_type import PyrogramType
|
||||||
|
|
||||||
|
|
||||||
class ReplyKeyboardRemove(Object):
|
class ReplyKeyboardRemove(PyrogramType):
|
||||||
"""Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and
|
"""Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and
|
||||||
display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent
|
display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent
|
||||||
by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a
|
by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a
|
||||||
@ -35,9 +35,9 @@ class ReplyKeyboardRemove(Object):
|
|||||||
keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet.
|
keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ID = 0xb0700023
|
|
||||||
|
|
||||||
def __init__(self, selective: bool = None):
|
def __init__(self, selective: bool = None):
|
||||||
|
super().__init__(None, None)
|
||||||
|
|
||||||
self.selective = selective
|
self.selective = selective
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user