async def back_access(data: str) -> str:
    inline_kb_to_choose = InlineKeyboardMarkup(row_width=6)
    temp = 1
    result_string = ''

    if data['type'] == "all":
        data = get_all_reminders()
        type_string = "reminders"
    elif data['type'] == "perm":
        data = get_permanent_reminders()
        type_string = "permanent reminders"
    elif data['type'] == "temp":
        data = get_temporary_reminders()
        type_string = "temporary reminders"
    elif data['type'] == "book":
        data = get_bookmarks()
        type_string = "bookmarks"
    else:
        raise KeyError
    if data:
        for elem in data:
            inline_btn = InlineKeyboardButton(temp,
                                              callback_data=f"edit_{elem[0]}")
            inline_kb_to_choose.insert(inline_btn)
            result_string += answer_forms(element=elem,
                                          position=temp,
                                          adding=True)
            temp += 1
    else:
        result_string, inline_kb_to_choose = f"No {type_string} in system.", remindersMenu
    return result_string, inline_kb_to_choose
Example #2
0
async def handler_show_bookmarks(
        message: Message,
        show_header: bool = True) -> Tuple[str, InlineKeyboardMarkup]:
    inline_kb_to_choose = InlineKeyboardMarkup(row_width=6)
    data = reminders.get_bookmarks()
    temp = 1
    result_string = ''

    await message.delete()
    if data:
        if show_header:
            await message.answer("Bookmarks:", reply_markup=anyRemindersMenu)
        for elem in data:
            inline_btn = InlineKeyboardButton(temp,
                                              callback_data=f"edit_{elem[0]}")
            inline_kb_to_choose.insert(inline_btn)
            result_string += answer_forms(element=elem,
                                          position=temp,
                                          adding=True)
            temp += 1

        await message.answer(result_string, reply_markup=inline_kb_to_choose)
    else:
        await message.answer("No bookmarks in system.",
                             reply_markup=remindersMenu)

    return result_string, inline_kb_to_choose
Example #3
0
async def process_date_temp(message: types.Message, state: FSMContext):
    async with state.proxy() as data:
        data['date'] = message.text

        answer = reminders.add_reminder(title=data['title'],
                                        date=data['date'],
                                        category='temp')

        await hand_clb.send_forms_answer(bot=bot,
                                         message=message,
                                         data=answer_forms(answer),
                                         markup=i_btn.inline_kb_edit1)
    await state.finish()