def show_debtors_by_group_callback(message): group = message.text group_id = Group.get_id_by_group(group) if group_id is False: bot.clear_step_handler_by_chat_id(message.from_user.id) bot.send_message(chat_id=message.from_user.id, text='Вибери пункт меню:', reply_markup=make_role_replykeyboard(studdekan_buttons)) else: debtors_list = ProfcomDebtor.get_debtors_by_group(group_id) if not debtors_list: message_text = 'В цій групі немає боржників' else: debtors_str = ''.join((f'<a href="t.me/{debtor.username}">' f'{debtor.name}</a> - {ProfcomDebtor.get_debt(debtor.id)}\n' for debtor in debtors_list)) message_text = f'Боржники групи {group}:\n{debtors_str}' bot.send_message(chat_id=message.from_user.id, text=message_text, parse_mode='html', disable_web_page_preview=True) bot.send_message(chat_id=message.from_user.id, text='Вибери пункт меню:', reply_markup=make_role_replykeyboard(studdekan_buttons))
def get_group_headman_assign(message): group = message.text group_id = Group.get_id_by_group(group) if group_id is False: bot.clear_step_handler_by_chat_id(message.from_user.id) bot.send_message( chat_id=message.from_user.id, text='Вибери пункт меню:', reply_markup=make_role_replykeyboard(studdekan_buttons)) else: if not Headman.get_headman_by_group(group_id): student_keyboard = make_keyboard( keyboard_type='student', elem_list=Student.get_students_by_group(group_id), marker=f'headman_{Group.get_group_by_id(group_id)}_') bot.send_message(chat_id=message.from_user.id, text='Вибери старосту:', reply_markup=student_keyboard) else: keyboard = InlineKeyboardMarkup() keyboard.add( InlineKeyboardButton( text= f'Змінити старосту {emojize(":repeat:", use_aliases=True)}', callback_data='change_headman')) bot.send_message( chat_id=message.from_user.id, text='Цій групі вже призначено старосту.\n' 'Якщо потрібно його змінити, скористайся командою ' f'{emojize(":point_down:", use_aliases=True)}', reply_markup=keyboard)
def get_group_for_profcomdebt(message): group = message.text group_id = Group.get_id_by_group(group) if group_id is False: bot.clear_step_handler_by_chat_id(message.from_user.id) bot.send_message(chat_id=message.from_user.id, text='Вибери пункт меню:', reply_markup=make_role_replykeyboard(studdekan_buttons)) else: student_keyboard = make_keyboard(keyboard_type='student', elem_list=[student for student in Student.get_students_by_group(group_id)], marker=f'debtor_{Group.get_group_by_id(group_id)}_') bot.send_message(chat_id=message.from_user.id, text='Вибери студента:', reply_markup=student_keyboard)
def get_group_headman_change(message): group = message.text group_id = Group.get_id_by_group(group) if group_id is False: bot.clear_step_handler_by_chat_id(message.from_user.id) bot.send_message( chat_id=message.from_user.id, text='Вибери пункт меню:', reply_markup=make_role_replykeyboard(studdekan_buttons)) else: student_keyboard = make_keyboard( keyboard_type='student', elem_list=Student.get_students_by_group(group_id), marker=f'chheadman_{Group.get_group_by_id(group_id)}_') bot.send_message(chat_id=message.from_user.id, text='Вибери нового старосту:', reply_markup=student_keyboard)
def get_group(message): group_id = Group.get_id_by_group(message.text) if group_id is False: bot.clear_step_handler_by_chat_id(message.from_user.id) bot.send_message(chat_id=message.from_user.id, text='Вибери свою групу:') bot.register_next_step_handler_by_chat_id(message.from_user.id, get_group) else: student = Student() student.id = message.from_user.id student.username = message.from_user.username student.group_id = group_id message = bot.send_message(chat_id=message.from_user.id, text='Введи ПІБ українською мовою') bot.register_next_step_handler(message, get_name, student)
def show_headman_info(message): group = message.text group_id = Group.get_id_by_group(group) if group_id is False: bot.clear_step_handler_by_chat_id(message.from_user.id) bot.send_message( chat_id=message.from_user.id, text='Вибери пункт меню:', reply_markup=make_role_replykeyboard(studdekan_buttons)) else: headman = Headman.get_headman_by_group(group_id) if not headman: keyboard = InlineKeyboardMarkup() keyboard.add( InlineKeyboardButton( text=f'Призначити старосту ' f'{emojize(":white_check_mark:", use_aliases=True)}', callback_data='assign_headman')) bot.send_message(chat_id=message.from_user.id, text=f'Групі {group} непризначено старосту.\n' 'Для призначення старости скористайся командою ' f'{emojize(":point_down:", use_aliases=True)}', reply_markup=keyboard) else: username = Student.get_student_by_id(headman.student_id).username name = Student.get_student_by_id(headman.student_id).name phone = Student.get_student_by_id(headman.student_id).phone bot.send_message( chat_id=message.from_user.id, text= f'Староста групи {group}: <a href="t.me/{username}">{name}</a>\n' f'Номер телефону: {phone}', parse_mode='html', disable_web_page_preview=True) bot.send_message( chat_id=message.from_user.id, text='Вибери пункт меню:', reply_markup=make_role_replykeyboard(studdekan_buttons))
def get_group_for_del_profcomdebt(message): group = message.text group_id = Group.get_id_by_group(group) if group_id is False: bot.clear_step_handler_by_chat_id(message.from_user.id) bot.send_message(chat_id=message.from_user.id, text='Вибери пункт меню:', reply_markup=make_role_replykeyboard(studdekan_buttons)) else: debtor_list = ProfcomDebtor.get_debtors_by_group(group_id) debtor_list_keyboard = InlineKeyboardMarkup() if not debtor_list: message_text = 'В цій групі немає боржників' else: debtor_list_keyboard = make_keyboard(keyboard_type='student', elem_list=debtor_list, marker='deldebtor_') message_text = 'Вибери боржника:' bot.send_message(chat_id=message.from_user.id, text=message_text, reply_markup=debtor_list_keyboard)
def check_fac(id_): if Student.get_student_by_id(id_).group_id != Group.get_id_by_group('other'): return True
def add_another_fac(message): Student.add_student( Student(id=message.from_user.id, username=message.from_user.username, group_id=Group.get_id_by_group('other')))