示例#1
0
def get_info(bot, update):
    helper = DBHelper()
    account_info = helper.show_account(update.message.chat_id)
    update.message.reply_text("=> Información de la cuenta, " \
                "\n\n* N° Cuenta: {} \n* Cliente: {} " \
                "\n* Saldo: ${}".format(account_info[0], account_info[1], account_info[2]))
    return ConversationHandler.END
示例#2
0
def active_account(bot, update):
    helper = DBHelper()
    helper.activate_account(update.message.chat_id)
    bot.send_message(chat_id=update.message.chat_id,
                     text="**Cuenta activada.**",
                     parse_mode=telegram.ParseMode.MARKDOWN)
    return ConversationHandler.END
示例#3
0
def show_recharges(bot, update):
    helper = DBHelper()
    mensaje = ""
    for recharge_item in helper.get_recharges(update.message.chat_id):
        mensaje += "=> Usted recargo a la cuenta N°{}, el monto de ${} el dia {}.\n".format(
            recharge_item[5], recharge_item[2], recharge_item[6])
    update.message.reply_text(mensaje)
示例#4
0
def show_transfers_entries(bot, update):
    helper = DBHelper()
    mensaje = "=> Transferencias Recibidas\n\n"
    for transfer_item in helper.get_transfers_receive(update.message.chat_id):
        mensaje += "* Cuenta N° {} - fecha {} monto ${}. \n".format(
            transfer_item[1], transfer_item[4], transfer_item[3])

    update.message.reply_text(mensaje)
示例#5
0
def show_transfers_sends(bot, update):
    helper = DBHelper()
    mensaje = "=> Transferencias Enviadas\n\n"
    for transfer_item in helper.get_transfers_sends(update.message.chat_id):
        mensaje += "* Cuenta N° {} - fecha {} - monto ${}. \n".format(
            transfer_item[2], transfer_item[4], transfer_item[3])

    update.message.reply_text(mensaje)
示例#6
0
def desactivate_account(bot, update):
    helper = DBHelper()
    helper.desactivate_account(update.message.chat_id)
    bot.send_message(
        chat_id=update.message.chat_id,
        text=
        "**Cuenta desactivada.** '/activar' para activar nuevamente su cuenta.",
        parse_mode=telegram.ParseMode.MARKDOWN)
    return ConversationHandler.END
示例#7
0
def show_withdraws(bot, update):
    helper = DBHelper()
    mensaje = "=> Mis Retiros \n\n"
    for withdraw_item in helper.get_withdraws(update.message.chat_id):
        mensaje += "* Fecha: {} saldo ${}, retiro: ${} - nuevo saldo: ${}.\n".format(
            withdraw_item[5], withdraw_item[2], withdraw_item[4],
            withdraw_item[3])

    update.message.reply_text(mensaje)
示例#8
0
def transfer_monto(bot, update):
    helper = DBHelper()
    if update.message.text == "{}".format(update.message.chat_id):
        update.message.reply_text(
            "=> No se pudo transferir dinero a su cuenta.")
        return ConversationHandler.END
    elif not helper.account_exists(update.message.text):
        update.message.reply_text("=> El N° de la cuenta no existe")
    else:
        update.message.reply_text("=> Digite el monto a transferir $ ")
        global id_and_monto
        id_and_monto = [update.message.text]
        return TRANSFERIR_EXECUTE
示例#9
0
def show_account(bot, update):
    helper = DBHelper()
    exists_acc = helper.account_exists(update.message.chat_id)
    if exists_acc:
        date_account = helper.show_account(update.message.chat_id)
        dates = "Numero de Cuenta: {} \nNombre del Cliente: {} \nSaldo en Cuenta: ${}".format(
            date_account[0], date_account[1], date_account[2])
        if date_account[3] == False:
            update.message.reply_text(
                "Cuenta desactivada '/activar' para activar.")
        else:
            update.message.reply_text(dates)
    else:
        update.message.reply_text(
            "No existe la cuenta. '/start' para crear una nueva cuenta.")
示例#10
0
def withdraw_logic(bot, update):
    helper = DBHelper()
    withdrawal = helper.show_account(update.message.chat_id)[2] - int(
        update.message.text)
    if withdrawal < 0:
        update.message.reply_text("¡Fondos insuficientes!")
    else:
        helper.withdraw_new(update.message.chat_id,
                            helper.show_account(update.message.chat_id)[2],
                            withdrawal, int(update.message.text), True)
        helper.withdraw(withdrawal, update.message.chat_id)
    update.message.reply_text("Su nuevo saldo es ${}".format(
        helper.show_account(update.message.chat_id)[2]))
    return ConversationHandler.END
示例#11
0
def add_recarga_execute(bot, update):
    id_and_monto_recarga.append(update.message.text)
    helper = DBHelper()
    if helper.show_account(update.message.chat_id)[2] < int(
            id_and_monto_recarga[1]):
        update.message.reply_text("Saldo insuficiente.")
    else:
        helper.recharges(
            update.message.chat_id, id_and_monto_recarga[1],
            helper.show_account(update.message.chat_id)[2],
            helper.show_account(update.message.chat_id)[2] -
            int(id_and_monto_recarga[1]), id_and_monto_recarga[0], True)
        helper.withdraw(
            helper.show_account(update.message.chat_id)[2] -
            int(id_and_monto_recarga[1]), update.message.chat_id)
        update.message.reply_text(
            "Usted a recargado la cuenta numero {} "
            "por el valor de ${} y su saldo actual es ${}".format(
                id_and_monto_recarga[0], id_and_monto_recarga[1],
                helper.show_account(update.message.chat_id)[2]))
示例#12
0
def add_balance_logic(bot, update):
    helper = DBHelper()
    sum = helper.show_account(update.message.chat_id)[2] + int(
        update.message.text)
    helper.add_balance(sum, update.message.chat_id)
    update.message.reply_text("=> Su saldo es ${}".format(
        helper.show_account(update.message.chat_id)[2]))
    return ConversationHandler.END
示例#13
0
def options(bot, update):
    helper = DBHelper()
    if helper.account_exists(update.message.chat_id) and helper.show_account(
            update.message.chat_id)[3]:
        reply_keyboard = [["Servicios"], ["Info cuenta"],
                          ["Desactivar cuenta"]]
        update.message.reply_text("¿Que deseas hacer?",
                                  reply_markup=ReplyKeyboardMarkup(
                                      reply_keyboard, one_time_keyboard=False))
        return OPTIONS
    elif helper.account_exists(update.message.chat_id):
        reply_keyboard = [["Activar cuenta"]]
        update.message.reply_text("¿Que deseas hacer?",
                                  reply_markup=ReplyKeyboardMarkup(
                                      reply_keyboard, one_time_keyboard=False))
        return OPTIONS
    elif not helper.account_exists(update.message.chat_id):
        reply_keyboard = [["Crear cuenta"]]
        update.message.reply_text("¿Que deseas hacer?",
                                  reply_markup=ReplyKeyboardMarkup(
                                      reply_keyboard, one_time_keyboard=False))
        return OPTIONS
示例#14
0
def create_account(bot, update):
    helper = DBHelper()
    if helper.account_exists(update.message.chat_id):
        bot.send_message(chat_id=update.message.chat_id,
                         text='**Ya tiene una cuenta registrada**',
                         parse_mode=telegram.ParseMode.MARKDOWN)
        return OPTIONS
    else:
        bot.send_message(
            chat_id=update.message.chat_id,
            text=
            '**Bienvenido.** En este momento nuestro equipo está creando su cuenta.',
            parse_mode=telegram.ParseMode.MARKDOWN)
        helper.create_account(update.message.chat_id,
                              "{}".format(update.message.from_user.first_name),
                              0, True)
        date_account = helper.show_account(update.message.chat_id)
        dates = "=> Su cuenta se creo con éxito, " \
            "los datos son:" \
            "\n\n* Numero de Cuenta: {} \n* Nombre del Cliente: {} " \
            "\n* Saldo en Cuenta: ${}".format(date_account[0], date_account[1], date_account[2])
        update.message.reply_text(dates)
        return OPTIONS
示例#15
0
def transfer_execute(bot, update):
    id_and_monto.append(update.message.text)
    helper = DBHelper()
    now_money = helper.show_account(update.message.chat_id)[2]
    name_user = helper.show_account(update.message.chat_id)[1]

    if now_money < int(id_and_monto[1]):
        update.message.reply_text("=> $$$ Saldos insuficientes.")
    else:
        now_money_recibe = helper.show_account(int(id_and_monto[0]))[2]
        helper.withdraw(now_money - int(id_and_monto[1]),
                        update.message.chat_id)
        helper.withdraw(now_money_recibe + int(id_and_monto[1]),
                        int(id_and_monto[0]))
        helper.transfer_to_account(update.message.chat_id,
                                   int(id_and_monto[0]), int(id_and_monto[1]),
                                   True)
        transfers = helper.get_transfers_sends(update.message.chat_id)
        last_transfer = transfers[len(transfers) - 1]
        update.message.reply_text(
            "=> Su transferencia de ${} a la cuenta No.{} fue exitosa.".format(
                last_transfer[3], last_transfer[2]))
        bot.send_message(
            chat_id=int(id_and_monto[0]),
            text="=> Usted ha recibido ${} del usuario {} con cuenta No.{}".
            format(int(id_and_monto[1]), name_user, update.message.chat_id))
    return ConversationHandler.END
示例#16
0
def get_balance(bot, update):
    helper = DBHelper()
    balance = helper.get_balance(update.message.chat_id)
    update.message.reply_text("=> Su saldo es ${}".format(balance[0]))
    return ConversationHandler.END