def set_subject(self, update: telegram.update, context): keyboard = [] for subject in Task.get_subjects_list(): keyboard.append( InlineKeyboardButton(subject, callback_data=(subject + '&'))) reply_markup = InlineKeyboardMarkup([keyboard]) context.bot.send_message(chat_id=update.effective_chat.id, text=CHOOSE_SUBJECT, reply_markup=reply_markup)
def callback_query_handler(self, update, context): # Handles inline buttons pressing query: CallbackQuery = update.callback_query query.answer() user_id = query.from_user.id query_type, task_id = query.data.split('&') if query_type == 'Hint': context.bot.send_message( chat_id=user_id, text= f'Hint: {self.task_manager.get_hint(user_id, int(task_id))}') elif query_type == 'Solution': context.bot.send_message( chat_id=user_id, text= f'Solution: {self.task_manager.get_solution(user_id, int(task_id))}' ) elif query_type in Task.get_subjects_list(): self.task_manager.set_subject(user_id, query_type) context.bot.send_message(chat_id=user_id, text=f'Subject set to {query_type}')