Add support for Game inline buttons. Add CallbackGame type
This commit is contained in:
parent
7d061a1b5c
commit
d5303285d6
@ -23,3 +23,4 @@ from .inline_keyboard_markup import InlineKeyboardMarkup
|
||||
from .keyboard_button import KeyboardButton
|
||||
from .reply_keyboard_markup import ReplyKeyboardMarkup
|
||||
from .reply_keyboard_remove import ReplyKeyboardRemove
|
||||
from .callback_game import CallbackGame
|
29
pyrogram/client/types/bots/callback_game.py
Normal file
29
pyrogram/client/types/bots/callback_game.py
Normal file
@ -0,0 +1,29 @@
|
||||
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||
# Copyright (C) 2017-2019 Dan Tès <https://github.com/delivrance>
|
||||
#
|
||||
# This file is part of Pyrogram.
|
||||
#
|
||||
# Pyrogram 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.
|
||||
#
|
||||
# Pyrogram 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 Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from ..pyrogram_type import PyrogramType
|
||||
|
||||
|
||||
class CallbackGame(PyrogramType):
|
||||
"""A placeholder, currently holds no information.
|
||||
|
||||
Use BotFather to set up your game.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(None)
|
@ -18,8 +18,9 @@
|
||||
|
||||
from pyrogram.api.types import (
|
||||
KeyboardButtonUrl, KeyboardButtonCallback,
|
||||
KeyboardButtonSwitchInline
|
||||
KeyboardButtonSwitchInline, KeyboardButtonGame
|
||||
)
|
||||
from .callback_game import CallbackGame
|
||||
from ..pyrogram_type import PyrogramType
|
||||
|
||||
|
||||
@ -58,7 +59,8 @@ class InlineKeyboardButton(PyrogramType):
|
||||
callback_data: bytes = None,
|
||||
url: str = None,
|
||||
switch_inline_query: str = None,
|
||||
switch_inline_query_current_chat: str = None):
|
||||
switch_inline_query_current_chat: str = None,
|
||||
callback_game: CallbackGame = None):
|
||||
super().__init__(None)
|
||||
|
||||
self.text = text
|
||||
@ -66,7 +68,7 @@ class InlineKeyboardButton(PyrogramType):
|
||||
self.callback_data = callback_data
|
||||
self.switch_inline_query = switch_inline_query
|
||||
self.switch_inline_query_current_chat = switch_inline_query_current_chat
|
||||
# self.callback_game = callback_game
|
||||
self.callback_game = callback_game
|
||||
# self.pay = pay
|
||||
|
||||
@staticmethod
|
||||
@ -95,6 +97,12 @@ class InlineKeyboardButton(PyrogramType):
|
||||
switch_inline_query=o.query
|
||||
)
|
||||
|
||||
if isinstance(o, KeyboardButtonGame):
|
||||
return InlineKeyboardButton(
|
||||
text=o.text,
|
||||
callback_game=CallbackGame()
|
||||
)
|
||||
|
||||
def write(self):
|
||||
if self.callback_data:
|
||||
return KeyboardButtonCallback(self.text, self.callback_data)
|
||||
@ -107,3 +115,6 @@ class InlineKeyboardButton(PyrogramType):
|
||||
|
||||
if self.switch_inline_query_current_chat:
|
||||
return KeyboardButtonSwitchInline(self.text, self.switch_inline_query_current_chat, same_peer=True)
|
||||
|
||||
if self.callback_game:
|
||||
return KeyboardButtonGame(self.text)
|
||||
|
Loading…
Reference in New Issue
Block a user