async def shop_rename_heroes_win(message): reguest = f"""UPDATE heroes SET nik_name = '{message.text}' WHERE user_id = {message.chat.id}; UPDATE resource SET diamond = diamond - 5 WHERE user_id = {message.chat.id} """ await sql.sql_insertscript(reguest) await message.answer(text=text_rename_nik_new % message.text, reply_markup=keyboard_main_menu())
async def process_name(message: types.Message, state: FSMContext): await state.finish() await sql.sql_insert( "UPDATE heroes SET nik_name = '%s' WHERE user_id = %s" % (message.text, message.chat.id)) await message.answer(text=texting.text_main_menu % message.text, reply_markup=keyboard.keyboard_main_menu())
async def got_payment(message: types.Message): await message.answer( 'Ура! Спасибо за оплату! Мы выполним ваш заказ на сумму `{} {}` как можно быстрее! ' 'Оставайтесь на связи. '.format( message.successful_payment.total_amount / 100, message.successful_payment.currency), parse_mode='Markdown', reply_markup=keyboard_main_menu())
async def congratulation(message, data): if data == "heroes": r_gold = random.randint(1, 50) cell_r, field = (await sql.sql_selectone( f"""SELECT battle_enemy.enemy_cell, resource.field FROM battle_enemy, resource WHERE battle_enemy.user_id = {message.chat.id} AND resource.user_id = {message.chat.id}""" )) text = f"Бой окончен:\n {texting.text_ataka_win % r_gold}" await sql.sql_insert( f'delete from battle_enemy where user_id == {message.chat.id}') await sql.sql_insert( f'delete from combinations where user_id = {message.chat.id}') time.sleep(2) # print(field) if field == 0: request = f""" UPDATE heroes SET experience_used = experience_used + 5 WHERE user_id = {message.chat.id}; UPDATE resource SET gold = gold + {r_gold} WHERE user_id = {message.chat.id}; UPDATE maps SET resource = 'null', lvl = 0, number=0, id=0 WHERE maps_id = {cell_r}; """ await sql.sql_insertscript(request) await recovery_energy(message) await recovery_health(message) await message.answer(text, reply_markup=keyboardmap()) await goto(message=message, call=" ") else: text += await mining_attack_win(message.chat.id) request = f""" UPDATE heroes SET experience_used = experience_used + 5 WHERE user_id = {message.chat.id}; UPDATE resource SET gold = gold + {r_gold}, field = 0 WHERE user_id = {message.chat.id}; Update heroes SET health_used = (SELECT health FROM heroes LEFT JOIN data_heroes ON heroes.lvlheroes = data_heroes.lvlheroes WHERE user_id = {message.chat.id}) """ await sql.sql_insertscript(request) await recovery_energy(message) await recovery_health(message) await message.answer(text, reply_markup=keyboardmap()) await field_goto(message) elif data == "enemy": await sql.sql_insert( f'delete from battle_enemy where user_id == {message.chat.id}') await sql.sql_insert( f'delete from combinations where user_id = {message.chat.id}') text = f"Бой окончен:\n Вы проиграли" await recovery_energy(message) await recovery_health(message) await message.answer(text, reply_markup=keyboard_main_menu())
async def search_user(message): user = (await sql.sql_selectone( "select count(user_id) from heroes where user_id = %s" % message.chat.id))[0] if user == 1: print("Пользователь есть") await message.answer(text=texting.text_user_is, reply_markup=keyboard.keyboard_main_menu()) else: await register_user(message) await message.answer(text=texting.text_start, reply_markup=keyboard.keyboard_start()) await bot.send_message(chat_id=765333440, text="Новый пользователь зарегистрирован")
async def function_buy(message, state): if message.text == button_buy_cancel: await message.answer(button_buy_cancel, reply_markup=keyboard_main_menu()) await state.finish() else: data = await number_check(message) if data == "Error_min": await message.answer("Повторите ввод. Минимальная покупка 1 💎") elif data == "Error_int": await message.answer("Повторите ввод. Число не корректно") elif data == "Ok": await state.finish() print(message.text) # await buy_tranzzo(message) await buy_qiwi(message)
async def buy_cancel(message: types.Message): await message.answer(texting.button_buy_cancel, reply_markup=keyboard.keyboard_main_menu())
async def back(message: types.Message): await message.answer(text=texting.button_back, reply_markup=keyboard.keyboard_main_menu())
async def stop(message: types.Message): await message.answer(text="🏘 Домой", reply_markup=keyboard.keyboard_main_menu())