async def user_statistic(msg: types.Message): user = User.get_user(msg.from_user.id) if user.clan_leader: await msg.answer(texts['user_statistic'].format( user.clan.id + 1, user.clan.color, user.clan_level, User.get_user_ref_count(msg.from_user.id), user.totem_animal, reward_calculation(user.user_id), Decimal(str(user.clan.balance)), user.eth_address, User.get_ref_link(msg.from_user.id) ), reply_markup=kb.get_about_menu(True)) await msg.answer(text=await UserHistory.get_history(msg.from_user.id)) else: await msg.answer(texts['user_statistic'].format( User.get_user_ref_count(msg.from_user.id), user.clan.id + 1, user.clan.color, user.clan_level, user.totem_animal, reward_calculation(user.user_id), Decimal(str(user.clan.balance)), user.eth_address, User.get_ref_link(msg.from_user.id) ), reply_markup=kb.get_about_menu()) await msg.answer(await UserHistory.get_history(msg.from_user.id))
async def check_transaction_status(c: types.CallbackQuery, state: FSMContext): user_id = c.from_user.id u = User.get_user(user_id) transaction_value = await get_transaction_value(u.eth_address) if transaction_value >= Decimal(str(config.ENTRY_COST)): await bot.send_message( user_id, texts['eth_address']['approve_processing_success'], reply_markup=kb.main_kb_approve) await c.message.delete_reply_markup() current_state = await state.get_state() User.user_approve(user_id=user_id) user = User.get_user(c.from_user.id) user.balance = transaction_value clan = Clan.get_clan(user.clan.id) clan.balance += transaction_value user.balance = transaction_value user.save() clan.save() if current_state is None: return await state.finish() await c.message.answer('Ваша реферальная ссылка - {}'.format( User.get_ref_link(c.message.from_user.id))) else: await bot.send_message( user_id, texts['eth_address']['approve_processing_decline']) await bot.send_message(user_id, texts['eth_address']['approve_address'].format( config.ENTRY_COST, config.TARGET_EPH_ADDRESS), reply_markup=kb.check_transaction_kb) await bot.answer_callback_query(c.id)
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'])
async def get_ref_link(msg: types.Message): await msg.answer(User.get_ref_link(msg.from_user.id))