def account_chosen(message): BOT.register_next_step_handler(message, amount_given) account = message.text user_id = message.from_user.id redis_helpers.store_transaction_from(account, user_id) BOT.send_message(user_id, 'Give amount:', reply_markup=types.ReplyKeyboardHide())
def account_to_chosen(message): BOT.register_next_step_handler(message, account_chosen) account_to = message.text user_id = message.from_user.id redis_helpers.store_transaction_to(account_to, user_id) accounts = redis_helpers.get_stored_resource('account', user_id) markup = types.ReplyKeyboardMarkup(one_time_keyboard=True, resize_keyboard=True) markup.add(*[acc['name'].encode('utf-8') for acc in accounts]) markup.add('/cancel') BOT.send_message(user_id, 'Choose account:', reply_markup=markup)
def transfer(message): BOT.register_next_step_handler(message, account_to_chosen) user_id = message.from_user.id redis_helpers.store_transaction_kind('transfer', user_id) try: accounts = redis_helpers.get_stored_resource('account', user_id) markup = types.ReplyKeyboardMarkup(one_time_keyboard=True, resize_keyboard=True) markup.add(*[acc['name'].encode('utf-8') for acc in accounts]) markup.add('/cancel') BOT.send_message(user_id, 'Choose account transfer to:', reply_markup=markup) except Exception as e: logger.warn(e)
def expense(message): BOT.register_next_step_handler(message, category_chosen) user_id = message.from_user.id redis_helpers.store_transaction_kind('expense', user_id) try: categories = redis_helpers.get_stored_resource('category', user_id) markup = types.ReplyKeyboardMarkup(one_time_keyboard=True, resize_keyboard=True) markup.add(*[cat['name'].encode('utf-8') for cat in categories if cat['kind'] == 'exp']) markup.add('/cancel') BOT.send_message(user_id, 'Choose category:', reply_markup=markup) except Exception as e: logger.warn(e)
def expense(message): BOT.register_next_step_handler(message, category_chosen) user_id = message.from_user.id redis_helpers.store_transaction_kind('expense', user_id) try: categories = redis_helpers.get_stored_resource('category', user_id) markup = types.ReplyKeyboardMarkup(one_time_keyboard=True, resize_keyboard=True) markup.add(*[ cat['name'].encode('utf-8') for cat in categories if cat['kind'] == 'exp' ]) markup.add('/cancel') BOT.send_message(user_id, 'Choose category:', reply_markup=markup) except Exception as e: logger.warn(e)