async def phone_step(message: types, state: FSMContext): try: data = await state.get_data() lang = data.get('lang') if message.text == '/start': markup = types.InlineKeyboardMarkup() markup.add( types.InlineKeyboardButton(text='лаЛЃЛЂ ' + "ЪЄиЪЄ║", callback_data='лаЛЃЛЂ')) markup.add( types.InlineKeyboardButton(text='мџл░ли ' + "ЪЄ░ЪЄ┐", callback_data='мџл░ли')) await message.answer(lang_phrases(1, 10), reply_markup=markup, parse_mode=HTML) await States.lang.set() elif message.text == '/delete': await delete(message) else: id = await is_phone(message.text) print(id) await state.update_data(id=id) if id: print('in id') await message.answer(lang_phrases(lang, 0), parse_mode=HTML) await States.id.set() else: await message.answer(lang_phrases(lang, 2), parse_mode=HTML) await States.phone.set() except Exception as e: await bot.send_message(877012379, str(e))
async def delete(message: types.Message): try: if message.text == '/start': markup = types.InlineKeyboardMarkup() markup.add( types.InlineKeyboardButton(text='лаЛЃЛЂ ' + "ЪЄиЪЄ║", callback_data='лаЛЃЛЂ')) markup.add( types.InlineKeyboardButton(text='мџл░ли ' + "ЪЄ░ЪЄ┐", callback_data='мџл░ли')) await message.answer(lang_phrases(1, 10), reply_markup=markup, parse_mode=HTML) await States.lang.set() list_of_students = select_by_id(message.chat.id) inline = types.InlineKeyboardMarkup() lang = 1 for i in list_of_students: lang = i[2] inline.add( types.InlineKeyboardButton(i[3], callback_data=str(i[3]) + '/' + str(message.chat.id))) inline.add( types.InlineKeyboardButton('лЮл░лил░л┤ Рєх', callback_data='/start')) await bot.send_message(message.chat.id, lang_phrases(lang, 15), reply_markup=inline) await States.delete.set() except Exception as e: await bot.send_message(877012379, str(e))
async def delete_step(query: types.CallbackQuery, state: FSMContext): print(query) if query.data == '/start': markup = types.InlineKeyboardMarkup() markup.add( types.InlineKeyboardButton(text='лаЛЃЛЂ ' + "ЪЄиЪЄ║", callback_data='лаЛЃЛЂ')) markup.add( types.InlineKeyboardButton(text='мџл░ли ' + "ЪЄ░ЪЄ┐", callback_data='мџл░ли')) await query.message.answer(lang_phrases(1, 10), reply_markup=markup, parse_mode=HTML) await States.lang.set() else: data = query.data data = data.split('/') name = data[0] chat_id = data[1] delete_from_chat(chat_id=chat_id, name=name) markup = types.InlineKeyboardMarkup() markup.add( types.InlineKeyboardButton(text='лаЛЃЛЂ ' + "ЪЄиЪЄ║", callback_data='лаЛЃЛЂ')) markup.add( types.InlineKeyboardButton(text='мџл░ли ' + "ЪЄ░ЪЄ┐", callback_data='мџл░ли')) await query.message.answer('лњЛІ ЛЃЛЂл┐лхЛѕлйлЙ лЙЛѓл┐лИЛЂл░л╗лИЛЂЛї!') await query.message.answer(lang_phrases(1, 10), reply_markup=markup, parse_mode=HTML) await States.lang.set()
async def lang_step(query: types.CallbackQuery, state: FSMContext): try: message = query.message if message.text == '/start': markup = types.InlineKeyboardMarkup() markup.add( types.InlineKeyboardButton(text='лаЛЃЛЂ ' + "ЪЄиЪЄ║", callback_data='лаЛЃЛЂ')) markup.add( types.InlineKeyboardButton(text='мџл░ли ' + "ЪЄ░ЪЄ┐", callback_data='мџл░ли')) await message.answer(lang_phrases(1, 10), reply_markup=markup, parse_mode=HTML) await States.lang.set() if message.text == '/delete': await delete(message) lang = query.data lang_code = 0 if lang == 'лаЛЃЛЂ': await state.update_data(lang=1) lang_code = 1 elif lang == 'мџл░ли': await state.update_data(lang=0) elif lang == 'again': data = await state.get_data() lang_code = data.get('lang') if lang_code == 1: lang = 'лаЛЃЛЂ' if lang_code == 0: lang = 'мџл░ли' if (lang != 'лаЛЃЛЂ') and (lang != 'мџл░ли'): markup = types.InlineKeyboardMarkup() markup.add( types.InlineKeyboardButton(text='лаЛЃЛЂ ' + "ЪЄиЪЄ║", callback_data='лаЛЃЛЂ')) markup.add( types.InlineKeyboardButton(text='мџл░ли ' + "ЪЄ░ЪЄ┐", callback_data='мџл░ли')) await message.answer(lang_phrases(lang, 10), reply_markup=markup, parse_mode=HTML) await States.lang.set() else: await message.answer(lang_phrases(lang_code, 1), parse_mode=HTML) await States.phone.set() except Exception as e: await bot.send_message(877012379, str(e))
async def start(message: types.Message): try: markup = types.InlineKeyboardMarkup() markup.add( types.InlineKeyboardButton(text='лаЛЃЛЂ ' + "ЪЄиЪЄ║", callback_data='лаЛЃЛЂ')) markup.add( types.InlineKeyboardButton(text='мџл░ли ' + "ЪЄ░ЪЄ┐", callback_data='мџл░ли')) await message.answer(text=lang_phrases(1, 10), reply_markup=markup, parse_mode=HTML) await States.lang.set() except Exception as e: await bot.send_message(877012379, str(e))
async def id_step(message: types.Message, state: FSMContext): try: data = await state.get_data() lang = data.get('lang') if message.text == '/start': markup = types.InlineKeyboardMarkup() markup.add( types.InlineKeyboardButton(text='лаЛЃЛЂ ' + "ЪЄиЪЄ║", callback_data='лаЛЃЛЂ')) markup.add( types.InlineKeyboardButton(text='мџл░ли ' + "ЪЄ░ЪЄ┐", callback_data='мџл░ли')) await message.answer(lang_phrases(1, 10), reply_markup=markup, parse_mode=HTML) await States.lang.set() elif message.text == '/delete': await delete(message) else: id = message.text i_d = data.get('id') id2 = await get_id_by_lesson(int(id)) if int(id) == int(i_d) or int(id) == int(id2): customer = await customers(id) name = '' try: name = await get_name(customer) except Exception as e: await bot.send_message(877012379, 'id_step ' + str(e)) await state.update_data(name=name) await state.update_data(id=id) create_table() insert(message.chat.id, id, lang, name.strip()) inline_markup = types.InlineKeyboardMarkup() inline_markup.add( types.InlineKeyboardButton(lang_phrases(lang, 4), callback_data='da')) inline_markup.add( types.InlineKeyboardButton(lang_phrases(lang, 5), callback_data='net')) await message.answer(lang_phrases(lang, 3).format(str(name)), reply_markup=inline_markup, parse_mode=HTML) await States.grade.set() else: markup = types.InlineKeyboardMarkup() markup.add( types.InlineKeyboardButton(lang_phrases(lang, 7), callback_data='again')) await message.answer(lang_phrases(lang, 8), parse_mode=HTML, reply_markup=markup) await States.lang.set() except Exception as e: await bot.send_message(877012379, str(e))
async def send_message(): try: l = select() print(l) for j in l: print(j) time.sleep(1) report = await get_grade(j[1]) bonus = '' note = '' done = '' tasks = '' right_task = '' for i in report: print(i) length = len(i) time_from = i[1] date = time_from[:10] topic = i[3] subject = i[2] if length == 7: done = i[4] bonus = i[5] note = i[6] elif length == 9: done = i[5] tasks = i[6] right_task = i[4] bonus = i[7] note = i[8] if bonus is None: bonus = '' if note is None: note = '' if date == str(datetime.datetime.today().date()): await bot.send_message(877012379, j[0]) print('here') await bot.send_message( j[0], lang_phrases(j[2], 12).format(j[3], date, subject, topic, tasks, done, right_task, bonus, note)) except Exception as e: await bot.send_message(877012379, str(e))
async def grade_step(query: types.CallbackQuery, state: FSMContext): try: data = await state.get_data() lang = data.get('lang') name = data.get('name') if query.data == 'da': await query.message.answer(lang_phrases(lang, 13), parse_mode=HTML) msg = await query.message.answer(lang_phrases(lang, 9), parse_mode=HTML) data = await state.get_data() id = data.get('id') report = await get_grade(int(id)) await msg.delete() if not report: await query.message.answer(lang_phrases(lang, 14), parse_mode=HTML) count = 0 for i in report: length = len(i) time_from = i[1] date = time_from[:10] topic = i[3] subject = i[2] bonus = '' note = '' done = '' tasks = '' right_task = '' if length == 7: done = i[4] bonus = i[5] note = i[6] elif length == 9: done = i[5] tasks = i[6] right_task = i[4] done = done + ' ' + get_percent(tasks, done) right_task = right_task + ' ' + get_percent( tasks, right_task) bonus = i[7] note = i[8] if bonus is None: bonus = '' if note is None: note = '' await query.message.answer( lang_phrases(lang, 12).format(name.strip(), date, subject, topic, tasks, done, right_task, bonus, note)) count += 1 # else: # await query.message.answer('лњ л┤л░лйлйЛІл╣ л╝лЙл╝лхлйЛѓ лЙЛєлхлйлЙл║ лйлхЛѓ') if count > 3: break await state.finish() elif query.data == 'net': markup = types.InlineKeyboardMarkup() markup.add( types.InlineKeyboardButton(lang_phrases(lang, 7), callback_data='again')) await query.message.answer(lang_phrases(lang, 8), parse_mode=HTML, reply_markup=markup) await States.lang.set() except Exception as e: await bot.send_message(877012379, str(e))