Added timetable
This commit is contained in:
34
keyboards/inline/timetable.py
Normal file
34
keyboards/inline/timetable.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import json
|
||||
|
||||
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
||||
|
||||
|
||||
BASE_PATH = 'configs/timetable'
|
||||
FILE = f'{BASE_PATH}/groups.json'
|
||||
|
||||
|
||||
def timetable(id: int = None):
|
||||
keyboard = InlineKeyboardMarkup()
|
||||
|
||||
with open(FILE, "r") as f:
|
||||
a = json.load(f)
|
||||
|
||||
if id is not None:
|
||||
if len(id.split(",")) > 1:
|
||||
links = []
|
||||
for i in id.split(","):
|
||||
if i == '': continue
|
||||
links.append(f"{BASE_PATH}/{i}")
|
||||
return links
|
||||
return [f"{BASE_PATH}/{id}"]
|
||||
|
||||
for key, value in a.items():
|
||||
if type(value) == type([]):
|
||||
tmp = ''
|
||||
for i in value:
|
||||
tmp += i
|
||||
tmp += ","
|
||||
keyboard.add(InlineKeyboardButton(key, callback_data=f"timetable|{str(tmp)}"))
|
||||
continue
|
||||
keyboard.add(InlineKeyboardButton(key, callback_data=f"timetable|{str(value)}"))
|
||||
return keyboard
|
Reference in New Issue
Block a user