Example #1
0
def playlist_choose_day() -> InlineKeyboardMarkup:
    day_start = Ether.get_closest().day
    btns = []
    for day in range(4):
        day = (day + day_start) % 7
        btns.append(_ikb(WEEK_DAYS[day], cb.CBPlaylistDay(day)))
    return InlineKeyboardMarkup(row_width=4).add(*btns)
Example #2
0
async def timetable(message: types.Message):
    text = ''
    for day_num, day_name in {0: 'Будни', 6: 'Воскресенье'}.items():
        text += f"{day_name} \n"
        for break_num, (start, stop) in others.ETHER_TIMES[day_num].items():
            text += f"   {start} - {stop}   {others.ETHER_NAMES[break_num]}\n"

    br = Ether.get_closest()
    if br.is_now():
        text += "\nЭфир прямо сейчас!"
    else:
        text += f"\nБлижайший эфир - {'сегодня' if br.is_today() else others.WEEK_DAYS[br.day]}," \
                f" {br.start_time.strftime('%H:%M')}"

    await message.answer(text)
Example #3
0
BAD_ORDER_BUT_OK = InlineKeyboardMarkup(row_width=1).add(
    _ikb(btns_text.BAD_ORDER_BUT_OK, cb.CBOrderBack()),
    _ikb(btns_text.CANCEL, cb.CBOrderCancel()))


#
async def order_choose_day() -> InlineKeyboardMarkup:
    today = DateTime.day_num()
    btns = []

    if (ether_now := Ether.now()) and await Broadcast(ether_now).get_free_time(
    ) > 3 * 60:  # кнопка сейчас если эфир+влазит
        btns.append(_ikb(NEXT_DAYS[-1], cb.CBOrderTime(today, ether_now.num)))

    if Ether.get_closest().is_today():  # кнопка сегодня
        btns.append(_ikb(NEXT_DAYS[0], cb.CBOrderDay(today)))

    for i in range(1, 4):  # завтра (1), послезавтра (2), послепослезавтра  (3)
        btns.append(_ikb(NEXT_DAYS[i], cb.CBOrderDay((today + i) % 7)))

    btns.append(_ikb(btns_text.CANCEL, cb.CBOrderCancel()))
    return InlineKeyboardMarkup(row_width=1).add(*btns)


async def order_choose_time(day: int,
                            attempts: int = 5) -> InlineKeyboardMarkup:
    btns = []
    for num in ETHER_TIMES[day]:
        ether = Ether(day, num)
        if ether.is_already_play_today():