def choose_option(update, context, data, reply):
     if data == _(tr.BACK, context):
         main_reply(reply, context)
         return State.FIRST_NODE
     context.user_data['subject'] = data
     reply(_(tr.START_INPUTING_NAMES, context))
     return State.READ_T
 def choose_option(update, context, data, reply):
     if data == ANSWER_TYPE_AGAIN:
         reply(_(tr.START_INPUTING_NAMES, context))
         return State.READ_T
     else:
         show_teacher_feedback(reply, data, context)
         main_reply(update.effective_user.send_message, context)
         return State.FIRST_NODE
 def choose_option(update, context, data, reply):
     if data == _(tr.BACK, context):
         main_reply(reply, context)
         return State.FIRST_NODE
     elif data == ANSWER_NOT_IN_LIST:
         reply(_(tr.INPUT_SUBJ_NAME, context))
         return State.ADD_NEW_SUBJECT
     context.user_data['subject'] = data
     reply(_(tr.INPUT_FIO, context))
     return State.ADD_T
def read_t(update: Update, context: CallbackContext):
    teachers = bd_worker.find_teachers(context.user_data['subject'],
                                       update.message.text)
    if len(teachers) == 0:
        update.message.reply_text(_(tr.TEACHER_NOT_FOUND, context))
    elif len(teachers) > 1:
        save_teachers_read_keyboards(teachers, context)
        show_teachers(update.message.reply_text, context)
        return State.READ_T_INLINE
    else:
        show_teacher_feedback(update.message.reply_text, teachers[0], context)
        main_reply(update.message.reply_text, context)
        return State.FIRST_NODE
def choose_action_type(update: Update, context: CallbackContext):
    # TODO back button
    reply_keyboard = [[_(tr.BACK, context)]]
    if update.message.text == _(tr.REVIEW_ADD, context):
        save_subject_keyboards(bd_worker.get_all_subjects(), context)
        show_subjects(update.message.reply_text, context)
        return State.ADD_TO_SUBJECT
    elif update.message.text == _(tr.REVIEW_READ, context):
        save_subject_read_keyboards(bd_worker.get_all_subjects(), context)
        show_subjects(update.message.reply_text, context)
        return State.READ_FROM_SUBJECT
    elif update.message.text == _(tr.BACK, context):
        main_reply(update.message.reply_text, context)
        return State.FIRST_NODE
    return None
def add_rating(update: Update, context: CallbackContext):
    if update.message.text.replace(',', '').replace('.', '').isnumeric() and 0 <= float(
            update.message.text.replace(',', '.')) <= 10:
        context.user_data['teacher_rating'] = update.message.text
        teacher = bd_worker.read_teacher(context.user_data['subject'],
                                         context.user_data['teacher_name'])
        if not teacher:
            bd_worker.add_new_teacher(context.user_data['subject'],
                                      context.user_data['teacher_name'],
                                      context.user_data['teacher_desc'],
                                      context.user_data['teacher_rating'])
        else:
            bd_worker.add_new_description(context.user_data['subject'],
                                          context.user_data['teacher_name'],
                                          context.user_data['teacher_desc'],
                                          context.user_data['teacher_rating'])
        update.message.reply_text(_(tr.EXCELLENT, context))
        main_reply(update.message.reply_text, context)
        return State.FIRST_NODE
    else:
        update.message.reply_text(
            _(tr.WRONG_RATING, context))
        return None
Example #7
0
def finish(send_first, send_second, context):
    answer = context.user_data[ANSWERS] + [context.user_data[ANSWER_COMMENT]]
    save_to_csv(context.user_data.get('lang', 'ru'), answer)
    send_first(_(tr.FEEDBACK_FINAL_PHRASE, context))
    utils.main_reply(send_second, context)
    return State.FIRST_NODE
Example #8
0
def stop(update, context):
    utils.main_reply(update.effective_user.send_message, context)
    return State.FIRST_NODE
Example #9
0
def choose_lang(update, context):
    data, reply = utils.answer_query(update, context)
    context.user_data['lang'] = data
    reply(_(tr.SUCCESSFULLY_SELECTED_LANG, context))
    utils.main_reply(update.effective_user.send_message, context)
    return State.FIRST_NODE