Example #1
0
async def repayment_of_loans_hamkorbank_password(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        update_log(user_id, get_log(user_id) + message.text)
        if message.text == get_dict('cancel', d):
            await bot.send_message(user_id, get_dict('section', d), reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
        elif str(message.text).isdecimal():
            await bot.send_message(user_id, get_dict('section', d), reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
    except Exception as e:
        logger_app.error("/handlers/payments.py\nMethod: repayment_of_loans_hamkorbank_password\n"+str(e))
Example #2
0
async def exchange_rates(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        update_log(user_id, get_log(user_id) + message.text)
        if message.text == get_dict('calculator', d):
            await bot.send_message(user_id,
                                   get_dict('section', d),
                                   reply_markup=markups.calculator(d))
            set_user_state(user_id, get_state_by_key('S_CALCULATOR'))
        elif message.text == get_dict('back', d):
            await bot.send_message(user_id,
                                   get_dict('general_hint', d),
                                   reply_markup=markups.general(d))
            set_user_state(user_id, get_state_by_key('S_GENERAL'))
        elif message.text == get_dict('main_menu', d):
            await bot.send_message(user_id,
                                   get_dict('main_menu_hint', d),
                                   reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
        else:
            await bot.send_message(user_id,
                                   get_dict('exchange_rates_data', d),
                                   reply_markup=markups.exchange_rates(d))
    except Exception as e:
        logger_app.error(
            "/handlers/exchange_rates.py\nMethod: exchange_rates\n" + str(e))
Example #3
0
async def minibank(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        update_log(user_id, get_log(user_id) + message.text)
        i = 0
        if message.text == get_dict('back', d):
            await bot.send_message(user_id,
                                   get_dict('main_menu_hint', d),
                                   reply_markup=markups.branches(d))
            set_user_state(user_id, get_state_by_key('S_BRANCH'))
        elif message.text == get_dict('main_menu', d):
            await bot.send_message(user_id,
                                   get_dict('section', d),
                                   reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
        else:
            while i < len(distinct_regions()):
                if message.text == get_region(distinct_regions()[i][0], d):
                    await bot.send_message(user_id,
                                           get_dict('section', d),
                                           reply_markup=markups.minibank(
                                               distinct_regions()[i][0], d))
                    set_user_state(user_id, distinct_regions()[i][0] + 'M')
                    break
                i = i + 1
    except Exception as e:
        logger_app.error("/handlers/atm.py\nMethod: minibank\n" + str(e))
Example #4
0
async def branch(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        update_log(user_id, get_log(user_id) + message.text)
        if message.text == get_dict('branches', d):
            await bot.send_message(user_id,
                                   get_dict('section', d),
                                   reply_markup=markups.regions(d))
            set_user_state(user_id, get_state_by_key('S_BRANCH_OFFICE_REGION'))
        elif message.text == get_dict('mini_bank', d):
            await bot.send_message(user_id,
                                   get_dict('section', d),
                                   reply_markup=markups.regions(d))
            set_user_state(user_id, get_state_by_key('S_MINI_BANK'))
        elif message.text == get_dict('atm', d):
            await bot.send_message(user_id,
                                   get_dict('section', d),
                                   reply_markup=markups.regions(d))
            set_user_state(user_id, get_state_by_key('S_ATM'))
        elif message.text == get_dict('back', d):
            await bot.send_message(user_id,
                                   get_dict('general_hint', d),
                                   reply_markup=markups.general(d))
            set_user_state(user_id, get_state_by_key('S_GENERAL'))
        elif message.text == get_dict('main_menu', d):
            await bot.send_message(user_id,
                                   get_dict('main_menu_hint', d),
                                   reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
        else:
            await bot.send_message(user_id, get_dict('section', d))
    except Exception as e:
        logger_app.error("/handlers/branches.py\nMethod: branch\n" + str(e))
Example #5
0
async def calculator(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        update_log(user_id, get_log(user_id) + message.text)
        if message.text == get_dict('purchase_currency', d):
            await bot.send_message(user_id,
                                   get_dict('purchase_warning', d),
                                   reply_markup=markups.cost(d))
            set_user_state(user_id, get_state_by_key('S_PURCHASE_CURRENCY'))
        elif message.text == get_dict('sale_currency', d):
            await bot.send_message(user_id,
                                   get_dict('sale_warning', d),
                                   reply_markup=markups.cost(d))
            set_user_state(user_id, get_state_by_key('S_SALE_CURRENCY'))
        elif message.text == get_dict('back', d):
            await bot.send_message(
                user_id,
                get_dict('cb_currency_rate', d) + ' \n\n ' +
                exchange_rate_parsing.cb_ex_rates + '\n\n\n' +
                get_dict('purchase_sale', d) + '\n\n' +
                exchange_rate_parsing.purchase_sale_ex_rates,
                reply_markup=markups.exchange_rates(d))
            set_user_state(user_id, get_state_by_key('S_EXCHANGE_RATES'))
        elif message.text == get_dict('main_menu', d):
            await bot.send_message(user_id,
                                   get_dict('main_menu_hint', d),
                                   reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
        else:
            await bot.send_message(user_id, get_dict('section', d))
    except Exception as e:
        logger_app.error("/handlers/exchange_rates.py\nMethod: calculator\n" +
                         str(e))
Example #6
0
async def start(message: types.Message):
    try:
        user_id = message.from_user.id
        first_name = message.from_user.first_name
        last_name = message.from_user.last_name
        username = message.from_user.username
        user = get_user(user_id)

        if user is None:
            await bot.send_message(
                user_id,
                "Выберите язык / Tilni tanlang / Тилни танланг",
                reply_markup=markups.lang_m)
            add_user(user_id, '', first_name, last_name, username,
                     get_state_by_key('S_START'))

        else:
            if not get_user_status(user_id)[0]:
                await bot.send_message(
                    user_id,
                    "Выберите язык / Tilni tanlang / Тилни танланг",
                    reply_markup=markups.lang_m)
                set_user_state(user_id, get_state_by_key('S_START'))
            else:
                d = get_lang(user_id)

                await bot.send_message(user_id,
                                       get_dict('section', d),
                                       reply_markup=markups.main_menu(d))
                set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
    except Exception as e:
        logger_app.error("/handlers/bot.py\nMethod: start\n" + str(e))
Example #7
0
async def purchase_currency(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        update_log(user_id, get_log(user_id) + message.text)
        if message.text == get_dict('back', d):
            await bot.send_message(user_id,
                                   get_dict('section', d),
                                   reply_markup=markups.calculator(d))
            set_user_state(user_id, get_state_by_key('S_CALCULATOR'))
        elif message.text == get_dict('main_menu', d):
            await bot.send_message(user_id,
                                   get_dict('main_menu_hint', d),
                                   reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
        elif message.text == get_dict('other_amount', d):
            await bot.send_message(user_id, get_dict('enter_amount', d))
        else:
            try:
                result = purchase_calculator(int(message.text), d)
                await bot.send_message(user_id, result)
                return
            except ValueError:
                try:
                    result = purchase_calculator(float(message.text), d)
                    await bot.send_message(user_id, result)
                    return
                except ValueError:
                    await bot.send_message(user_id,
                                           get_dict('error_enter_number', d))
    except Exception as e:
        logger_app.error(
            "/handlers/exchange_rates.py\nMethod: purchase_currency\n" +
            str(e))
Example #8
0
async def confirm_number(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        get_expire = 'SELECT expire FROM app_users where user_id=(%s);'
        cur = conn.cursor()
        cur.execute(get_expire, (str(user_id), ))
        row = cur.fetchone()
        if row[0] > dt.datetime.now():
            if message.text == str(get_code(user_id)):
                set_log(user_id, get_phone_number(user_id))
                update_user_status(user_id)
                await bot.send_message(user_id,
                                       get_dict('main_menu_hint', d),
                                       reply_markup=markups.main_menu(d))
                set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
            else:
                await bot.send_message(user_id, get_dict('error_sms_code', d))
        else:

            await bot.send_message(
                user_id,
                "Выберите язык / Tilni tanlang / Тилни танланг",
                reply_markup=markups.lang_m)
            set_user_state(user_id, get_state_by_key('S_START'))

    except Exception as e:
        print(e)
async def contribution(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        update_log(user_id, get_log(user_id) + message.text)
        if message.text == get_dict('national_currency', d):
            await bot.send_message(
                user_id,
                get_dict('section', d),
                reply_markup=markups.contribution_online_branch(d))
            set_user_state(
                user_id, get_state_by_key('S_CONTRIBUTION_NATIONAL_CURRENCY'))
        elif message.text == get_dict('contribution_us_dollar', d):
            await bot.send_message(
                user_id,
                get_dict('section', d),
                reply_markup=markups.contribution_online_branch(d))
            set_user_state(user_id,
                           get_state_by_key('S_CONTRIBUTION_US_DOLLAR'))
        elif message.text == get_dict('back', d):
            await bot.send_message(user_id,
                                   get_dict('individual_hint', d),
                                   reply_markup=markups.individual(d))
            set_user_state(user_id, get_state_by_key('S_INDIVIDUAL'))
        elif message.text == get_dict('main_menu', d):
            await bot.send_message(user_id,
                                   get_dict('main_menu_hint', d),
                                   reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
        else:
            await bot.send_message(user_id, get_dict('section', d))
    except Exception as e:
        logger_app.error(
            "/handlers/individual_deposit.py\nMethod: contribution\n" + str(e))
Example #10
0
async def bo_navoi(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        update_log(user_id, get_log(user_id) + message.text)
        if message.text == get_dict('back', d):
            await bot.send_message(user_id,
                                   get_dict('section', d),
                                   reply_markup=markups.regions(d))
            set_user_state(user_id, get_state_by_key('S_BRANCH_OFFICE_REGION'))
        elif message.text == get_dict('main_menu', d):
            await bot.send_message(user_id,
                                   get_dict('main_menu_hint', d),
                                   reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
        else:
            await send_location(message.text, d, user_id, '12')
    except Exception as e:
        logger_app.error("/handlers/branches.py\nMethod: bo_navoi\n" + str(e))
Example #11
0
async def minibank_buk(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        update_log(user_id, get_log(user_id) + message.text)
        if message.text == get_dict('back', d):
            await bot.send_message(user_id,
                                   get_dict('section', d),
                                   reply_markup=markups.regions(d))
            set_user_state(user_id, get_state_by_key('S_MINI_BANK'))
        elif message.text == get_dict('main_menu', d):
            await bot.send_message(user_id,
                                   get_dict('main_menu_hint', d),
                                   reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
        else:
            await send_location(message.text, d, user_id, '06')
    except Exception as e:
        logger_app.error("/handlers/atm.py\nMethod: minibank_buk\n" + str(e))
Example #12
0
async def payments(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        update_log(user_id, get_log(user_id) + message.text)
        cards = ''
        if message.text == get_dict('my_cards', d):
            cardsList = get_card_json(user_id)
            if len(cardsList) > 0:
                for card in cardsList:
                    cards = cards + card[1] + '\n'
                await bot.send_message(user_id,
                                       get_dict('your_cards', d) + '\n\n' +
                                       cards,
                                       reply_markup=markups.cards_menu(d))
            else:
                await bot.send_message(user_id,
                                       get_dict('card_check', d),
                                       reply_markup=markups.cards_menu(d))
            set_user_state(user_id, get_state_by_key('S_CARD_MENU'))
        elif message.text == get_dict('back', d):
            await bot.send_message(user_id,
                                   get_dict('main_menu_hint', d),
                                   reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
        elif message.text == get_dict('card_to_card_transfers', d):
            await bot.send_message(user_id,
                                   get_dict('enter_card_number', d),
                                   reply_markup=markups.cancel(d))
            set_user_state(user_id, get_state_by_key('S_CARD_TO_CARD'))
        elif message.text == get_dict('repayment_of_loans', d):
            await bot.send_message(user_id, get_dict('developing', d))
        elif message.text == get_dict('mobile_operators', d):
            await bot.send_message(
                user_id,
                get_dict('payment_mobile_operators', d),
                reply_markup=markups.payment_mobile_operators(user_id, d))
            set_user_state(user_id,
                           get_state_by_key('S_PAYMENT_MOBILE_OPERATORS'))
        else:
            await bot.send_message(user_id, get_dict('payments_hint', d))
    except Exception as e:
        logger_app.error("/handlers/payments.py\nMethod: payments\n" + str(e))
async def legal_entity_bills(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        update_log(user_id, get_log(user_id) + message.text)
        if message.text == get_dict('back', d):
            await bot.send_message(user_id,
                                   get_dict('legal_entity_hint', d),
                                   reply_markup=markups.legal_entity(d))
            set_user_state(user_id, get_state_by_key('S_LEGAL_ENTITY'))
        elif message.text == get_dict('main_menu', d):
            await bot.send_message(user_id,
                                   get_dict('main_menu_hint', d),
                                   reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
        elif message.text == get_dict('balance_state', d):
            str_get = ''
            #accountTurnover = legal_entityAccountTurnover(163302497)
            accountTurnover = legal_entityAccountTurnover(user_id)

            if len(accountTurnover) > 0:
                for i in range(len(accountTurnover)):
                    resp = send_get_accountTurnOver(accountTurnover[i])

                    saldoOut = (("{:,}".format(
                        int(resp['responseBody']['saldoOut']) / 100)).replace(
                            ',', ' '))
                    name = resp['responseBody']['name']
                    accExternal = resp['responseBody']['accExternal']
                    str_get = str_get + '\n' + name[:80] + '\n' + accExternal + '\n' + get_dict(
                        'remainder', d) + ' ' + saldoOut + ' ' + get_dict(
                            'sum', d) + '\n'
                await bot.send_message(
                    user_id,
                    get_dict('account_status_message', d) + '\n' + str_get)
            else:
                await bot.send_message(user_id, get_dict('no_ext_account', d))
        elif message.text == get_dict('cardindex_1', d):
            k1 = 'SELECT * FROM "legal_entityAccountTurnover" WHERE phone_number=(SELECT phone_number FROM app_users WHERE user_id=(%s)) AND "codeCoa"=(%s);'
            cur = conn.cursor()
            cur.execute(k1, (str(user_id), '96319'))
            accountTurnover = cur.fetchall()
            str_get = ''
            if len(accountTurnover) > 0:
                for i in range(len(accountTurnover)):
                    resp = send_get_accountTurnOver(accountTurnover[i])
                    saldoOut = (("{:,}".format(
                        int(resp['responseBody']['saldoOut']) / 100)).replace(
                            ',', ' '))
                    name = resp['responseBody']['name']
                    accExternal = resp['responseBody']['accExternal']
                    str_get = str_get + '\n' + name[:80] + '\n' + accExternal + '\n' + get_dict(
                        'remainder', d) + ' ' + saldoOut + ' ' + get_dict(
                            'sum', d) + '\n'
                await bot.send_message(
                    user_id,
                    get_dict('account_status_message', d) + '\n' + str_get)
            else:
                await bot.send_message(user_id, get_dict('no_ext_account', d))
        elif message.text == get_dict('cardindex_2', d):
            k2 = 'SELECT * FROM "legal_entityAccountTurnover" WHERE phone_number=(SELECT phone_number FROM app_users WHERE user_id=(%s)) AND "codeCoa"=(%s);'
            cur = conn.cursor()
            cur.execute(k2, (str(user_id), '96321'))
            accountTurnover = cur.fetchall()
            str_get = ''
            if len(accountTurnover) > 0:
                for i in range(len(accountTurnover)):
                    resp = send_get_accountTurnOver(accountTurnover[i])
                    saldoOut = (("{:,}".format(
                        int(resp['responseBody']['saldoOut']) / 100)).replace(
                            ',', ' '))
                    name = resp['responseBody']['name']
                    accExternal = resp['responseBody']['accExternal']
                    str_get = str_get + '\n' + name[:80] + '\n' + accExternal + '\n' + get_dict(
                        'remainder', d) + ' ' + saldoOut + ' ' + get_dict(
                            'sum', d) + '\n'
                await bot.send_message(
                    user_id,
                    get_dict('account_status_message', d) + '\n' + str_get)
            else:
                await bot.send_message(user_id, get_dict('no_ext_account', d))
    except Exception as e:
        logger_app.error(
            "/handlers/legal_entity_bills.py\nMethod: legal_entity_bills\n" +
            str(e))
Example #14
0
async def individual(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        update_log(user_id, get_log(user_id) + message.text)
        if message.text == get_dict('cards', d):
            await bot.send_message(user_id,
                                   get_dict('section', d),
                                   reply_markup=markups.cards(d))
            set_user_state(user_id, get_state_by_key('S_CARD'))
        elif message.text == get_dict('contributions', d):
            await bot.send_message(user_id,
                                   get_dict('section', d),
                                   reply_markup=markups.deposits_individual(d))
            set_user_state(user_id,
                           get_state_by_key('S_CONTRIBUTION_INDIVIDUAL'))
        elif message.text == get_dict('loans', d):
            if markups.buttons(d, 'individual_loans'
                               )["keyboard"][0][0] is None or markups.buttons(
                                   d,
                                   'individual_loans')["keyboard"][0][0] == '':
                set_user_state(user_id, get_state_by_key('S_INDIVIDUAL'))
                if get_buttons(d, 'individual_loans')[0][4]:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'individual_loans')[0][2],
                        reply_markup=markups.inline_keyboards(
                            d, 'individual_loans',
                            get_buttons(d, 'individual_loans')[0][0]))
                else:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'individual_loans')[0][2])
            else:
                await bot.send_message(user_id,
                                       get_dict('section', d),
                                       reply_markup=markups.buttons(
                                           d, 'individual_loans'))
                set_user_state(user_id, get_state_by_key('S_LOAN'))
        elif message.text == get_dict('money_transfers', d):
            if markups.buttons(
                    d, 'individual_money_transfer'
            )["keyboard"][0][0] is None or markups.buttons(
                    d, 'individual_money_transfer')["keyboard"][0][0] == '':
                set_user_state(user_id, get_state_by_key('S_INDIVIDUAL'))
                if get_buttons(d, 'individual_money_transfer')[0][4]:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'individual_money_transfer')[0][2],
                        reply_markup=markups.inline_keyboards(
                            d, 'individual_money_transfer',
                            get_buttons(d, 'individual_money_transfer')[0][0]))
                else:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'individual_money_transfer')[0][2])
            else:
                await bot.send_message(user_id,
                                       get_dict('section', d),
                                       reply_markup=markups.buttons(
                                           d, 'individual_money_transfer'))
                set_user_state(user_id, get_state_by_key('S_MONEY_TRANSFER'))
        elif message.text == get_dict('tariffs', d):
            if markups.buttons(
                    d, 'individual_tariffs'
            )["keyboard"][0][0] is None or markups.buttons(
                    d, 'individual_tariffs')["keyboard"][0][0] == '':
                set_user_state(user_id, get_state_by_key('S_INDIVIDUAL'))
                if get_buttons(d, 'individual_tariffs')[0][4]:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'individual_tariffs')[0][2],
                        reply_markup=markups.inline_keyboards(
                            d, 'individual_tariffs',
                            get_buttons(d, 'individual_tariffs')[0][0]))
                else:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'individual_tariffs')[0][2])
            else:
                await bot.send_message(user_id,
                                       get_dict('section', d),
                                       reply_markup=markups.buttons(
                                           d, 'individual_tariffs'))
                set_user_state(user_id,
                               get_state_by_key('S_INDIVIDUAL_TARIFFS'))
        elif message.text == get_dict('mobile_application', d):
            if markups.buttons(
                    d, 'individual_mobile_app'
            )["keyboard"][0][0] is None or markups.buttons(
                    d, 'individual_mobile_app')["keyboard"][0][0] == '':
                set_user_state(user_id, get_state_by_key('S_INDIVIDUAL'))
                if get_buttons(d, 'individual_mobile_app')[0][4]:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'individual_mobile_app')[0][2],
                        reply_markup=markups.inline_keyboards(
                            d, 'individual_mobile_app',
                            get_buttons(d, 'individual_mobile_app')[0][0]))
                else:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'individual_mobile_app')[0][2])
            else:
                await bot.send_message(user_id,
                                       get_dict('section', d),
                                       reply_markup=markups.buttons(
                                           d, 'individual_mobile_app'))
                set_user_state(user_id,
                               get_state_by_key('S_INDIVIDUAL_MOBILE'))

        elif message.text == get_dict('back', d):
            await bot.send_message(user_id,
                                   get_dict('main_menu_hint', d),
                                   reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
        else:
            await bot.send_message(user_id, get_dict('individual_hint', d))
    except Exception as e:
        logger_app.error("/handlers/individual.py\nMethod: individual\n" +
                         str(e))
Example #15
0
async def legal_entity(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        update_log(user_id, get_log(user_id) + message.text)
        if message.text == get_dict('back', d):
            await bot.send_message(user_id,
                                   get_dict('main_menu_hint', d),
                                   reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
        elif message.text == get_dict('my_bills', d):
            await bot.send_message(user_id,
                                   get_dict('section', d),
                                   reply_markup=markups.my_bills(d))
            set_user_state(user_id, get_state_by_key('S_BALANCE_OPER'))
        elif message.text == get_dict('loans', d):
            if markups.buttons(d, 'legal_loans'
                               )["keyboard"][0][0] is None or markups.buttons(
                                   d, 'legal_loans')["keyboard"][0][0] == '':
                set_user_state(user_id, get_state_by_key('S_LEGAL_ENTITY'))
                if get_buttons(d, 'legal_loans')[0][4]:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'legal_loans')[0][2],
                        reply_markup=markups.inline_keyboards(
                            d, 'legal_loans',
                            get_buttons(d, 'legal_loans')[0][0]))
                else:
                    await bot.send_message(user_id,
                                           get_buttons(d, 'legal_loans')[0][2])
            else:
                await bot.send_message(user_id,
                                       get_dict('section', d),
                                       reply_markup=markups.buttons(
                                           d, 'legal_loans'))
                set_user_state(user_id,
                               get_state_by_key('S_LOAN_LEGAL_ENTITY'))
        elif message.text == get_dict('hamkor_pay_for_business', d):
            if markups.buttons(
                    d, 'legal_accepting_payment'
            )["keyboard"][0][0] is None or markups.buttons(
                    d, 'legal_accepting_payment')["keyboard"][0][0] == '':
                set_user_state(user_id, get_state_by_key('S_LEGAL_ENTITY'))
                if get_buttons(d, 'legal_accepting_payment')[0][4]:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'legal_accepting_payment')[0][2],
                        reply_markup=markups.inline_keyboards(
                            d, 'legal_accepting_payment',
                            get_buttons(d, 'legal_accepting_payment')[0][0]))
                else:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'legal_accepting_payment')[0][2])
            else:
                await bot.send_message(user_id,
                                       get_dict('section', d),
                                       reply_markup=markups.buttons(
                                           d, 'legal_accepting_payment'))
                set_user_state(user_id,
                               get_state_by_key('S_LEGAL_ACCEPTING_PAYMENT'))
        elif message.text == get_dict('deposit', d):
            if markups.buttons(d, 'legal_deposit'
                               )["keyboard"][0][0] is None or markups.buttons(
                                   d, 'legal_deposit')["keyboard"][0][0] == '':
                set_user_state(user_id, get_state_by_key('S_LEGAL_ENTITY'))
                if get_buttons(d, 'legal_deposit')[0][4]:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'legal_deposit')[0][2],
                        reply_markup=markups.inline_keyboards(
                            d, 'legal_deposit',
                            get_buttons(d, 'legal_deposit')[0][0]))
                else:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'legal_deposit')[0][2])
            else:
                await bot.send_message(user_id,
                                       get_dict('section', d),
                                       reply_markup=markups.buttons(
                                           d, 'legal_deposit'))
                set_user_state(user_id, get_state_by_key('S_LEGAL_DEPOSIT'))
        elif message.text == get_dict('other_services', d):
            if markups.buttons(
                    d, 'legal_other_services'
            )["keyboard"][0][0] is None or markups.buttons(
                    d, 'legal_other_services')["keyboard"][0][0] == '':
                set_user_state(user_id, get_state_by_key('S_LEGAL_ENTITY'))
                if get_buttons(d, 'legal_other_services')[0][4]:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'legal_other_services')[0][2],
                        reply_markup=markups.inline_keyboards(
                            d, 'legal_other_services',
                            get_buttons(d, 'legal_other_services')[0][0]))
                else:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'legal_other_services')[0][2])
            else:
                await bot.send_message(user_id,
                                       get_dict('section', d),
                                       reply_markup=markups.buttons(
                                           d, 'legal_other_services'))
                set_user_state(user_id, get_state_by_key('S_OTHER_SERVICES'))
        elif message.text == get_dict('internet_banking', d):
            if markups.buttons(
                    d, 'legal_internet_banking'
            )["keyboard"][0][0] is None or markups.buttons(
                    d, 'legal_internet_banking')["keyboard"][0][0] == '':
                set_user_state(user_id, get_state_by_key('S_LEGAL_ENTITY'))
                if get_buttons(d, 'legal_internet_banking')[0][4]:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'legal_internet_banking')[0][2],
                        reply_markup=markups.inline_keyboards(
                            d, 'legal_internet_banking',
                            get_buttons(d, 'legal_internet_banking')[0][0]))
                else:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'legal_internet_banking')[0][2])
            else:
                await bot.send_message(user_id,
                                       get_dict('section', d),
                                       reply_markup=markups.buttons(
                                           d, 'legal_internet_banking'))
                set_user_state(
                    user_id,
                    get_state_by_key('S_LEGAL_ENTITY_INTERNET_BANKING'))
        elif message.text == get_dict('tariffs', d):
            if markups.buttons(
                    d, 'legal_entity_tariffs'
            )["keyboard"][0][0] is None or markups.buttons(
                    d, 'legal_entity_tariffs')["keyboard"][0][0] == '':
                set_user_state(user_id, get_state_by_key('S_LEGAL_ENTITY'))
                if get_buttons(d, 'legal_entity_tariffs')[0][4]:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'legal_entity_tariffs')[0][2],
                        reply_markup=markups.inline_keyboards(
                            d, 'legal_entity_tariffs',
                            get_buttons(d, 'legal_entity_tariffs')[0][0]))
                else:
                    await bot.send_message(
                        user_id,
                        get_buttons(d, 'legal_entity_tariffs')[0][2])
            else:
                await bot.send_message(user_id,
                                       get_dict('section', d),
                                       reply_markup=markups.buttons(
                                           d, 'legal_entity_tariffs'))
                set_user_state(user_id, get_state_by_key('S_LEGAL_TARIFFS'))
        else:
            await bot.send_message(user_id, get_dict('legal_entity_hint', d))
    except Exception as e:
        logger_app.error("/handlers/legal_entity.py\nMethod: legal_entity\n" +
                         str(e))
Example #16
0
async def general(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        update_log(user_id, get_log(user_id) + message.text)
        if message.text == get_dict('exchange_rates', d):
            await bot.send_message(user_id, get_dict('cb_currency_rate', d)+' \n\n '+exchange_rate_parsing.cb_ex_rates+'\n\n\n'+get_dict('purchase_sale', d)+'\n\n'+exchange_rate_parsing.purchase_sale_ex_rates, reply_markup=markups.exchange_rates(d))
            set_user_state(user_id, get_state_by_key('S_EXCHANGE_RATES'))
        elif message.text == get_dict('branch_offices', d):
            await bot.send_message(user_id, get_dict('section', d), reply_markup=markups.branches(d))
            set_user_state(user_id, get_state_by_key('S_BRANCH'))
        elif message.text == get_dict('back', d):
            await bot.send_message(user_id, get_dict('main_menu_hint', d), reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
    except Exception as e:
        logger_app.error("/handlers/general.py\nMethod: general\n"+str(e))
Example #17
0
async def cards(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        update_log(user_id, get_log(user_id) + message.text)
        if message.text == get_dict('uzcard', d):
            if markups.buttons(d, 'individual_cards_uzcard')["keyboard"][0][0] is None or markups.buttons(d, 'individual_cards_uzcard')["keyboard"][0][0] == '':
                set_user_state(user_id, get_state_by_key('S_CARD'))
                if get_buttons(d, 'individual_cards_uzcard')[0][4]:
                    await bot.send_message(user_id, get_buttons(d, 'individual_cards_uzcard')[0][2], reply_markup=markups.inline_keyboards(d, 'individual_cards_uzcard', get_buttons(d,'individual_cards_uzcard')[0][0]))
                else:
                    await bot.send_message(user_id, get_buttons(d, 'individual_cards_uzcard')[0][2])
            else:
                await bot.send_message(user_id, get_dict('section', d), reply_markup=markups.buttons(d, 'individual_cards_uzcard'))
                set_user_state(user_id, get_state_by_key('S_UZCARD'))
        elif message.text == get_dict('humo', d):
            if markups.buttons(d, 'individual_cards_humo')["keyboard"][0][0] is None or markups.buttons(d, 'individual_cards_humo')["keyboard"][0][0] == '':
                set_user_state(user_id, get_state_by_key('S_CARD'))
                if get_buttons(d, 'individual_cards_humo')[0][4]:
                    await bot.send_message(user_id, get_buttons(d, 'individual_cards_humo')[0][2], reply_markup=markups.inline_keyboards(d, 'individual_cards_humo', get_buttons(d,'individual_cards_humo')[0][0]))
                else:
                    await bot.send_message(user_id, get_buttons(d, 'individual_cards_humo')[0][2])
            else:
                await bot.send_message(user_id, get_dict('section', d), reply_markup=markups.buttons(d, 'individual_cards_humo'))
                set_user_state(user_id, get_state_by_key('S_HUMO'))
        elif message.text == get_dict('visa', d):
            if markups.buttons(d, 'individual_cards_visa')["keyboard"][0][0] is None or markups.buttons(d, 'individual_cards_visa')["keyboard"][0][0] == '':
                set_user_state(user_id, get_state_by_key('S_CARD'))
                if get_buttons(d, 'individual_cards_visa')[0][4]:
                    await bot.send_message(user_id, get_buttons(d, 'individual_cards_visa')[0][2], reply_markup=markups.inline_keyboards(d, 'individual_cards_visa', get_buttons(d,'individual_cards_visa')[0][0]))
                else:
                    await bot.send_message(user_id, get_buttons(d, 'individual_cards_visa')[0][2])
            else:
                await bot.send_message(user_id, get_dict('section', d), reply_markup=markups.buttons(d, 'individual_cards_visa'))
                set_user_state(user_id, get_state_by_key('S_VISA'))
        elif message.text == get_dict('union_pay', d):
            if markups.buttons(d, 'individual_cards_unionpay')["keyboard"][0][0] is None or markups.buttons(d, 'individual_cards_unionpay')["keyboard"][0][0] == '':
                set_user_state(user_id, get_state_by_key('S_CARD'))
                if get_buttons(d, 'individual_cards_unionpay')[0][4]:
                    await bot.send_message(user_id, get_buttons(d, 'individual_cards_unionpay')[0][2], reply_markup=markups.inline_keyboards(d, 'individual_cards_unionpay', get_buttons(d,'individual_cards_unionpay')[0][0]))
                else:
                    await bot.send_message(user_id, get_buttons(d, 'individual_cards_unionpay')[0][2])
            else:
                await bot.send_message(user_id, get_dict('section', d), reply_markup=markups.buttons(d, 'individual_cards_unionpay'))
                set_user_state(user_id, get_state_by_key('S_UNION_PAY'))
        elif message.text == get_dict('main_menu', d):
            await bot.send_message(user_id, get_dict('main_menu_hint', d), reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
        elif message.text == get_dict('back', d):
            await bot.send_message(user_id, get_dict('individual_hint', d), reply_markup=markups.individual(d))
            set_user_state(user_id, get_state_by_key('S_INDIVIDUAL'))
        else:
            await bot.send_message(user_id, get_dict('section', d))
    except Exception as e:
        logger_app.error("/handlers/individual_cards.py\nMethod: cards\n" + str(e))
async def contribution_national_currency(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        update_log(user_id, get_log(user_id) + message.text)
        if message.text == get_dict('in_branches', d):
            if markups.buttons(
                    d, 'individual_deposit_national_currency_branch'
            )["keyboard"][0][0] is None or markups.buttons(
                    d, 'individual_deposit_national_currency_branch'
            )["keyboard"][0][0] == '':
                set_user_state(
                    user_id,
                    get_state_by_key('S_CONTRIBUTION_NATIONAL_CURRENCY'))
                if get_buttons(
                        d,
                        'individual_deposit_national_currency_branch')[0][4]:
                    await bot.send_message(
                        user_id,
                        get_buttons(
                            d, 'individual_deposit_national_currency_branch')
                        [0][2],
                        reply_markup=markups.inline_keyboards(
                            d, 'individual_deposit_national_currency_branch',
                            get_buttons(
                                d,
                                'individual_deposit_national_currency_branch')
                            [0][0]))
                else:
                    await bot.send_message(
                        user_id,
                        get_buttons(
                            d, 'individual_deposit_national_currency_branch')
                        [0][2])
            else:
                await bot.send_message(
                    user_id,
                    get_dict('section', d),
                    reply_markup=markups.buttons(
                        d, 'individual_deposit_national_currency_branch'))
                set_user_state(
                    user_id,
                    get_state_by_key(
                        'S_CONTRIBUTION_NATIONAL_CURRENCY_BRANCHES'))
        elif message.text == get_dict('online', d):
            if markups.buttons(
                    d, 'individual_deposit_national_currency_online'
            )["keyboard"][0][0] is None or markups.buttons(
                    d, 'individual_deposit_national_currency_online'
            )["keyboard"][0][0] == '':
                set_user_state(
                    user_id,
                    get_state_by_key('S_CONTRIBUTION_NATIONAL_CURRENCY'))
                if get_buttons(
                        d,
                        'individual_deposit_national_currency_online')[0][4]:
                    await bot.send_message(
                        user_id,
                        get_buttons(
                            d, 'individual_deposit_national_currency_online')
                        [0][2],
                        reply_markup=markups.inline_keyboards(
                            d, 'individual_deposit_national_currency_online',
                            get_buttons(
                                d,
                                'individual_deposit_national_currency_online')
                            [0][0]))
                else:
                    await bot.send_message(
                        user_id,
                        get_buttons(
                            d, 'individual_deposit_national_currency_online')
                        [0][2])
            else:
                await bot.send_message(
                    user_id,
                    get_dict('section', d),
                    reply_markup=markups.buttons(
                        d, 'individual_deposit_national_currency_online'))
                set_user_state(
                    user_id,
                    get_state_by_key(
                        'S_CONTRIBUTION_NATIONAL_CURRENCY_ONLINE'))
        elif message.text == get_dict('back', d):
            await bot.send_message(user_id,
                                   get_dict('section', d),
                                   reply_markup=markups.deposits_individual(d))
            set_user_state(user_id,
                           get_state_by_key('S_CONTRIBUTION_INDIVIDUAL'))
        elif message.text == get_dict('main_menu', d):
            await bot.send_message(user_id,
                                   get_dict('main_menu_hint', d),
                                   reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
        else:
            await bot.send_message(user_id, get_dict('section', d))
    except Exception as e:
        logger_app.error(
            "/handlers/individual_deposit.py\nMethod: contribution_national_currency\n"
            + str(e))
Example #19
0
async def card_menu(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        update_log(user_id, get_log(user_id) + message.text)
        if message.text == get_dict('balance', d):
            cards_list = get_all_cards(user_id)
            res = ''
            if len(cards_list) > 0:
                key = load_key()
                f = Fernet(key)
                res = get_dict('card_balance', d) + '\n\n'
                for row in cards_list:
                    decrypted_card = f.decrypt(bytes((row[2])[2:-1], encoding='utf8'))
                    balance = api.getCardBalance(decrypted_card.decode(), row[1])
                    if balance['msgrespdata']['errorCode'] == '0':
                        res = res + "💳 " + row[0] + '\n💰' + "{:,.2f}".format(
                            (int(balance["msgrespdata"]["response"]["balance"]) / 100)) + ' ' + get_dict('sum',
                                                                                                         d) + '\n\n'
                await bot.send_message(user_id, res)
            else:
                await bot.send_message(user_id, get_dict('card_check', d))
        elif message.text == get_dict('statement', d):
            await bot.send_message(user_id, get_dict('developing', d))
        elif message.text == get_dict('block', d):
            await bot.send_message(user_id, get_dict('developing', d))
        elif message.text == get_dict('add_new_card', d):
            await bot.send_message(user_id, get_dict('create_card_agreement', d), reply_markup=markups.create_card_agreement(d))
            set_user_state(user_id, get_state_by_key('S_CREATE_CARD_AGREEMENT'))
            files_list = os.listdir(config['OFFER_PATH']['path']+d)
            for i in files_list:
                file = open(config['OFFER_PATH']['path'] + d + '/' + i, 'rb')
                await bot.send_document(user_id, file)
        elif message.text == get_dict('main_menu', d):
            await bot.send_message(user_id, get_dict('main_menu_hint', d), reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
        elif message.text == get_dict('back', d):
            await bot.send_message(user_id, get_dict('section', d), reply_markup=markups.payments(d))
            set_user_state(user_id, get_state_by_key('S_PAYMENTS'))
        else:
            await bot.send_message(user_id, get_dict('section', d))
    except Exception as e:
        logger_app.error("/handlers/individual_cards.py\nMethod: card_menu\n" + str(e))
Example #20
0
async def settings(message: types.Message):
    try:
        user_id = message.from_user.id
        d = get_lang(user_id)
        update_log(user_id, get_log(user_id) + message.text)
        if message.text == get_dict('change_lang', d):
            if d == 1:
                await bot.send_message(user_id, get_dict('choose_lang', d), reply_markup=markups.change_lang_rus(d))
            elif d == 2:
                await bot.send_message(user_id, get_dict('choose_lang', d), reply_markup=markups.change_lang_latin(d))
            elif d == 3:
                await bot.send_message(user_id, get_dict('choose_lang', d), reply_markup=markups.change_lang_cyrillic(d))
            set_user_state(user_id, get_state_by_key('S_CHANGE_LANG'))
        elif message.text == get_dict('back', d):
            await bot.send_message(user_id, get_dict('main_menu_hint', d), reply_markup=markups.main_menu(d))
            set_user_state(user_id, get_state_by_key('S_GET_MAIN_MENU'))
        else:
            await bot.send_message(user_id, get_dict('section', d))
    except Exception as e:
        logger_app.error("/handlers/settings.py\nMethod: settings\n"+str(e))