mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-22 22:45:09 +01:00
Adding CallbackQuery #232
This commit is contained in:
parent
c2f5309cbf
commit
93e19dc2ae
2 changed files with 33 additions and 0 deletions
|
@ -43,6 +43,7 @@ from .nullhandler import NullHandler
|
|||
from .emoji import Emoji
|
||||
from .parsemode import ParseMode
|
||||
from .message import Message
|
||||
from .callbackquery import CallbackQuery
|
||||
from .choseninlineresult import ChosenInlineResult
|
||||
from .inlinekeyboardbutton import InlineKeyboardButton
|
||||
from .inlinekeyboardmarkup import InlineKeyboardMarkup
|
||||
|
@ -116,6 +117,7 @@ __all__ = ('Audio',
|
|||
'Chat',
|
||||
'ChatAction',
|
||||
'ChosenInlineResult',
|
||||
'CallbackQuery',
|
||||
'Contact',
|
||||
'Document',
|
||||
'Emoji',
|
||||
|
|
|
@ -16,3 +16,34 @@
|
|||
#
|
||||
# You should have received a copy of the GNU Lesser Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents a Telegram
|
||||
CallbackQuery"""
|
||||
|
||||
from telegram import TelegramObject, Message, User
|
||||
|
||||
|
||||
class CallbackQuery(TelegramObject):
|
||||
"""This object represents a Telegram CallbackQuery."""
|
||||
|
||||
def __init__(self,
|
||||
id,
|
||||
from_user,
|
||||
data):
|
||||
# Required
|
||||
self.id = id
|
||||
self.from_user = from_user
|
||||
self.data = data
|
||||
# Optionals
|
||||
self.message = kwargs.get('message')
|
||||
self.inline_message_id = kwargs.get('inline_message_id', '')
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
if not data:
|
||||
return None
|
||||
|
||||
data['from_user'] = User.de_json(data.get('from'))
|
||||
data['message'] = Message.de_json(data.get('message'))
|
||||
|
||||
return CallbackQuery(**data)
|
||||
|
|
Loading…
Reference in a new issue