Added timetable

This commit is contained in:
2023-02-19 00:51:52 +02:00
parent f735b691e4
commit 3d5a2eb1c7
8 changed files with 83 additions and 3 deletions

View 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