tg_bot/Keyboard.py

31 lines
707 B
Python
Raw Permalink Normal View History

2024-12-06 14:20:29 +03:00
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