31 lines
707 B
Python
31 lines
707 B
Python
|
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
|
||
|
|
||
|
|
||
|
class Keyboard:
|
||
|
|
||
|
def __init__(self):
|
||
|
self.keyboard = []
|
||
|
self.options = []
|
||
|
|
||
|
def get_keyboard(self):
|
||
|
return self.keyboard
|
||
|
|
||
|
def add_to_keyboard(self, data: InlineKeyboardButton | list):
|
||
|
self.keyboard.append(data)
|
||
|
|
||
|
def clear_keyboard(self):
|
||
|
self.keyboard = []
|
||
|
|
||
|
def create_keyboard(self):
|
||
|
return InlineKeyboardMarkup(self.get_keyboard())
|
||
|
|
||
|
def add_option(self, key, value):
|
||
|
self.options.append({key: value})
|
||
|
|
||
|
def get_option(self, key: str):
|
||
|
for option in self.options:
|
||
|
if key in option:
|
||
|
return option[key]
|
||
|
|
||
|
return None
|