python-telegram-bot/telegram/replykeyboardmarkup.py

38 lines
1.3 KiB
Python
Raw Normal View History

2015-07-09 03:33:13 +02:00
#!/usr/bin/env python
2015-07-12 15:39:11 +02:00
from .replymarkup import ReplyMarkup
2015-07-09 03:33:13 +02:00
class ReplyKeyboardMarkup(ReplyMarkup):
def __init__(self,
keyboard,
resize_keyboard=None,
one_time_keyboard=None,
selective=None):
self.keyboard = keyboard
self.resize_keyboard = resize_keyboard
self.one_time_keyboard = one_time_keyboard
self.selective = selective
@staticmethod
def de_json(data):
return ReplyKeyboardMarkup(keyboard=data.get('keyboard', None),
2015-07-09 04:38:07 +02:00
resize_keyboard=data.get(
'resize_keyboard', None
),
one_time_keyboard=data.get(
'one_time_keyboard', None
),
2015-07-09 03:33:13 +02:00
selective=data.get('selective', None))
def to_dict(self):
data = {'keyboard': self.keyboard}
2015-07-09 03:33:13 +02:00
if self.resize_keyboard:
data['resize_keyboard'] = self.resize_keyboard
2015-07-09 03:33:13 +02:00
if self.one_time_keyboard:
data['one_time_keyboard'] = self.one_time_keyboard
2015-07-09 03:33:13 +02:00
if self.selective:
data['selective'] = self.selective
return data