コード例 #1
0
async def address_processing(msg: types.Message, state: FSMContext):
    if validate_ethereum_address(msg.text):
        if User.eth_address_unical(msg.text):
            if User.eth_address_exist(msg.from_user.id):
                User.set_eth_address(msg.from_user.id, msg.text)
            else:
                User.set_eth_address(msg.from_user.id, msg.text)
            await EthereumAddress.check_transaction.set()
            if User.is_clan_leader(msg.from_user.id):
                user = User.get_user(msg.from_user.id)
                clan_id = user.clan.id + 1
                await msg.answer(
                    texts['eth_address']['approve_address_for_admin'].format(clan_id, User.get_ref_link(user.user_id)),
                    reply_markup=kb.main_kb_approve)
                User.user_approve(msg.from_user.id)
                await state.finish()
            else:
                await msg.answer(texts['eth_address']['approve_address'].format(
                    config.ENTRY_COST,
                    config.TARGET_EPH_ADDRESS
                ), reply_markup=kb.check_transaction_kb)
                await state.finish()
        else:
            u = User.get_user(msg.from_user.id)
            if u.eth_address == msg.text:
                User.set_eth_address(u.user_id, msg.text)

                await state.finish()
            else:
                await msg.answer(texts['eth_address']['address_decline'])
    else:
        await msg.answer(texts['eth_address']['address_decline'])
コード例 #2
0
async def start(msg: types.Message):
    if not User.user_exists(msg.from_user.id):
        User.create_user(msg)
        await msg.answer(texts['start']['new_user'], reply_markup=kb.main_kb_start)
    elif User.user_is_approved(msg.from_user.id):
        await msg.answer('Welcome back', reply_markup=kb.main_kb_approve)
    else:
        await msg.answer(texts['start']['new_user'], reply_markup=kb.main_kb_start)
    if not User.eth_address_exist(user_id=msg.from_user.id):
        await msg.answer(texts['eth_address']['request'])
        await EthereumAddress.get_address.set()
コード例 #3
0
async def change_address(msg: types.Message, state: FSMContext):
    if validate_ethereum_address(msg.text):
        if User.eth_address_unical(msg.text):
            if User.eth_address_exist(msg.from_user.id):
                User.set_eth_address(msg.from_user.id, msg.text)
                await msg.answer(texts['eth_address']['address_change_success'])
                if not User.user_is_approved(msg.from_user.id):
                    await msg.answer(texts['eth_address']['approve_address'].format(
                        config.ENTRY_COST,
                        config.TARGET_EPH_ADDRESS
                    ), reply_markup=kb.check_transaction_kb)
                await state.finish()
            else:
                await msg.answer(texts['eth_address']['address_decline'])
        else:
            await msg.answer(texts['eth_address']['address_decline'])
    else:
        await msg.answer(texts['eth_address']['address_decline'])