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 assign_grade(message): subjects_keyboard = make_keyboard('subject', Subject.get_subjects(), 'gradesubject_') bot.send_message(chat_id=message.from_user.id, text='Виберіть предмет:', reply_markup=subjects_keyboard)
def get_subject(call): subjects_keyboard = make_keyboard('subject', Subject.get_subjects(), 'getfilesubject_') bot.edit_message_text(chat_id=call.from_user.id, message_id=call.message.message_id, text='Вибери предмет:', reply_markup=subjects_keyboard)
def get_event_for_del(call): event_keyboard = make_keyboard(keyboard_type='event', elem_list=Event.get_all_events(), marker='eventdelete_') bot.edit_message_text(chat_id=call.from_user.id, message_id=call.message.message_id, text='Який захід видалити?', reply_markup=event_keyboard)
def get_event_visitors(call): event_keyboard = make_keyboard(keyboard_type='event', elem_list=Event.get_all_events(), marker='eventvisitor_') bot.edit_message_text(chat_id=call.from_user.id, message_id=call.message.message_id, text='Учасники якого заходу?', reply_markup=event_keyboard)
def choose_cathedra(message): cathedra_keyboard = make_keyboard(keyboard_type='cathedra', elem_list=Cathedra.get_cathedras(), marker='teachercathedra_') bot.edit_message_text(chat_id=message.from_user.id, message_id=message.message.message_id, text='Вибери кафедру:', reply_markup=cathedra_keyboard)
def add_profcomdebtor(call): group_keyboard = make_keyboard(keyboard_type='group', elem_list=Group.get_groups(), marker='debtorgroup_') bot.send_message(chat_id=call.from_user.id, text='Вибери групу:', reply_markup=group_keyboard) bot.register_next_step_handler_by_chat_id(call.from_user.id, get_group_for_profcomdebt)
def get_debtors_by_group(call): group_keyboard = make_keyboard(keyboard_type='group', elem_list=Group.get_groups(), marker='grdebtor_') bot.send_message(chat_id=call.from_user.id, text='Вибери групу:', reply_markup=group_keyboard) bot.register_next_step_handler_by_chat_id(call.from_user.id, show_debtors_by_group_callback)
def add_extragrade(message): group_keyboard = make_keyboard(keyboard_type='group', elem_list=Group.get_groups(), marker='extragradegroup_') bot.send_message(chat_id=message.from_user.id, text='Вибери групу:', reply_markup=group_keyboard) bot.register_next_step_handler_by_chat_id(message.from_user.id, get_group_for_extragrade)
def headman_assignment(call): group_keyboard = make_keyboard(keyboard_type='group', elem_list=Group.get_groups(), marker='headmangroup_') bot.send_message(chat_id=call.from_user.id, text='Вибери групу:', reply_markup=group_keyboard) bot.register_next_step_handler_by_chat_id(call.from_user.id, get_group_headman_assign)
def headman_changing(call): group_keyboard = make_keyboard(keyboard_type='group', elem_list=Group.get_groups(), marker='chheadgroup_') bot.send_message(chat_id=call.from_user.id, text='Змінити старосту групи:', reply_markup=group_keyboard) bot.register_next_step_handler_by_chat_id(call.from_user.id, get_group_headman_change)
def get_subject_for_grade(call): subject_id = call.data.split('_')[1] grade_type_keyboard = make_keyboard('gradetype', GradeType.get_gradetypes(), f'gradetype_{subject_id}_') bot.edit_message_text(chat_id=call.from_user.id, message_id=call.message.message_id, text='Виберіть тип оцінки:', reply_markup=grade_type_keyboard)
def get_grade_type(call): subject_id = call.data.split('_')[1] grade_type_id = call.data.split('_')[2] group_keyboard = make_keyboard( 'student', Group.get_groups()[:4], f'studentsgroup_{subject_id}_{grade_type_id}_') bot.edit_message_text(chat_id=call.from_user.id, message_id=call.message.message_id, text='Виберіть групу:', reply_markup=group_keyboard)
def register(message): group_keyboard = make_keyboard(keyboard_type='group', elem_list=Group.get_groups(), marker='group_') bot.delete_message(chat_id=message.from_user.id, message_id=message.message.message_id) bot.send_message(chat_id=message.from_user.id, text='Вибери свою групу:', reply_markup=group_keyboard) bot.register_next_step_handler_by_chat_id(message.from_user.id, get_group)
def choose_teacher(call): cathedra_id = call.data.split('_')[1] teachers_info_keyboard = make_keyboard( keyboard_type='teacher', elem_list=Teacher.get_teachers_by_cathedra(cathedra_id), marker='showteacher_') bot.edit_message_text(chat_id=call.from_user.id, message_id=call.message.message_id, text='Викладачі кафедри', reply_markup=teachers_info_keyboard, parse_mode='html')
def register_for_admins(message): if Student.get_student_by_id(message.from_user.id) is None: group_keyboard = make_keyboard(keyboard_type='group', elem_list=Group.get_groups(), marker='group_') bot.send_message(chat_id=message.from_user.id, text='Вибери свою групу:', reply_markup=group_keyboard) bot.register_next_step_handler_by_chat_id(message.from_user.id, get_group) else: bot.send_message(chat_id=message.from_user.id, text='Ти вже зареєстрований') bot.clear_step_handler_by_chat_id(chat_id=message.from_user.id)
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_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 teacher_student_communication(message): subjects_keyboard = make_keyboard('subject', Subject.get_subjects(), 'methodsubject_') bot.send_message(chat_id=message.from_user.id, text='Виберіть предмет:', reply_markup=subjects_keyboard)