示例#1
0
def make_keyboard_menu_manage_categories(session, telegram_user_id,
                                         category_manager: CategoryManager):
    if category_manager.check_any_categories(session, telegram_user_id):
        keyboard = ReplyKeyboardMarkup(add_buttons_exit_and_back(
            [[Buttons.add, Buttons.edit, Buttons.delete]]),
                                       resize_keyboard=True)
    else:
        keyboard = ReplyKeyboardMarkup(add_buttons_exit_and_back(
            [[Buttons.add]]),
                                       resize_keyboard=True)
    return keyboard
示例#2
0
def to_add_category(update: Update, context: CallbackContext):
    context.user_data['back_func'] = to_menu_manage_categories
    bot.send_message(chat_id=update.message.from_user.id,
                     text=text_add_category(),
                     reply_markup=ReplyKeyboardMarkup(
                         add_buttons_exit_and_back([]), resize_keyboard=True))
    return States.TO_ADD_CATEGORY
示例#3
0
def to_edit_amount_money(update, context):
    context.user_data['back_func'] = to_choose_action_edit
    update.message.reply_text(text=text_to_write_money(),
                              reply_markup=ReplyKeyboardMarkup(
                                  add_buttons_exit_and_back([]),
                                  resize_keyboard=True))
    return States.TO_EDIT_WRITE_MONEY
示例#4
0
def to_write_money(update: Update, context: CallbackContext):
    context.user_data['back_func'] = to_choose_type_transaction
    transaction_adder = context.user_data['transaction_adder']
    bot.send_message(chat_id=update.message.from_user.id,
                     text=transaction_adder.text_to_write_money(),
                     reply_markup=ReplyKeyboardMarkup(
                         add_buttons_exit_and_back([]), resize_keyboard=True))
    return States.TO_WRITE_MONEY
示例#5
0
def to_choose_date(update: Update, context: CallbackContext):
    context.user_data['back_func'] = to_choose_category
    bot.send_message(chat_id=update.message.from_user.id,
                     text=text_to_choose_date(),
                     reply_markup=ReplyKeyboardMarkup(
                         add_buttons_exit_and_back([buttons_days]),
                         resize_keyboard=True),
                     parse_mode=telegram.ParseMode.HTML)
    return States.TO_CHOOSE_DATE
示例#6
0
def to_write_edit_category(update: Update, context: CallbackContext):
    context.user_data['back_func'] = to_edit_category
    bot.send_message(
        chat_id=update.message.from_user.id,
        text=text_write_edit_category(context.user_data['old_edit_category']),
        parse_mode=telegram.ParseMode.HTML,
        reply_markup=ReplyKeyboardMarkup(add_buttons_exit_and_back([]),
                                         resize_keyboard=True))
    return States.TO_WRITE_EDIT_CATEGORY
示例#7
0
def send_message_to_choose_category(telegram_user_id, amount_money):
    with session_scope() as session:
        user = session.query(User).filter(User.telegram_user_id == telegram_user_id).first()
        buttons = make_buttons_for_choose_category(count_buttons_per_row=config['buttons_per_row'],
                                                   categories=CategoryEarning.get_all_categories(session, user.id))
    buttons = add_buttons_exit_and_back(buttons)
    keyboard = ReplyKeyboardMarkup(buttons, resize_keyboard=True)
    bot.send_message(chat_id=telegram_user_id,
                     text=text_to_choose_category(amount_money),
                     parse_mode=telegram.ParseMode.HTML,
                     reply_markup=keyboard)
示例#8
0
def to_edit_category(update: Update, context: CallbackContext):
    context.user_data['back_func'] = to_menu_manage_categories
    with session_scope() as session:
        categories = context.user_data['category_manager'].get_all_categories(
            session, update.message.from_user.id)
        buttons = make_buttons_for_choose_category(config['buttons_per_row'],
                                                   categories)
    bot.send_message(chat_id=update.message.from_user.id,
                     text=text_edit_category(),
                     reply_markup=ReplyKeyboardMarkup(
                         add_buttons_exit_and_back(buttons),
                         resize_keyboard=True),
                     parse_mode=telegram.ParseMode.HTML)
    return States.TO_EDIT_CATEGORY
示例#9
0
 def get_keyboard_choose_categories(self, session):
     categories = CategoryEarning.get_all_categories(session, self.user.id)
     buttons = make_buttons_for_choose_category(config['buttons_per_row'],
                                                categories)
     return ReplyKeyboardMarkup(add_buttons_exit_and_back(buttons),
                                resize_keyboard=True)
示例#10
0
def make_keyboard_choose_limits(ids_limits: dict):
    buttons = make_buttons_for_choose_limits(4, list(ids_limits.keys()))
    return ReplyKeyboardMarkup(add_buttons_exit_and_back(buttons),
                               resize_keyboard=True)
示例#11
0
def get_keyboard_category_limit(categories):
    keyboard_categories = make_buttons_for_choose_category(
        config['buttons_per_row'], categories)
    keyboard_categories.insert(0, [text_button_general_category])
    return ReplyKeyboardMarkup(add_buttons_exit_and_back(keyboard_categories),
                               resize_keyboard=True)
示例#12
0
text_button_weekly = 'Недельный'
text_button_monthly = 'Месячный'
text_button_general_category = 'По всем категориям'
text_button_type = 'Тип'
text_button_category = 'Категория'
text_button_amount_money = 'Количество денег'

keyboard_main_menu_limits_exist = ReplyKeyboardMarkup(add_button_exit(
    [[Buttons.add, Buttons.delete], [Buttons.edit]]),
                                                      resize_keyboard=True)

keyboard_main_menu_limits_non_exist = ReplyKeyboardMarkup(add_button_exit(
    [[Buttons.add]]),
                                                          resize_keyboard=True)

keyboard_choose_type_limit = ReplyKeyboardMarkup(add_buttons_exit_and_back(
    [[text_button_daily, text_button_weekly], [text_button_monthly]]),
                                                 resize_keyboard=True)

keyboard_choose_action_edit = ReplyKeyboardMarkup(add_buttons_exit_and_back(
    [[text_button_type, text_button_category, text_button_amount_money]]),
                                                  resize_keyboard=True)


def get_keyboard_category_limit(categories):
    keyboard_categories = make_buttons_for_choose_category(
        config['buttons_per_row'], categories)
    keyboard_categories.insert(0, [text_button_general_category])
    return ReplyKeyboardMarkup(add_buttons_exit_and_back(keyboard_categories),
                               resize_keyboard=True)