bot.py
def message_handler(message):
    """If the bot state for a message/call sender is SURVEY1.

       if an entered survey name exists, switch to SURVEY3 state.
           if the sender is the survey creator, send the assigned answer and
           the 'View, Collect, Back>>' markup.
           else, send the assigned answer and the 'Collect, Back>>' markup.

       else, send the assigned answer and the 'Create Survey' markup."""
    ans = answers['VIEW']
    markup = telebot.types.InlineKeyboardMarkup()

    if survey.survey_check(message):
        survey.save_survey(message)
        state.save_state(message, state.states['SURVEY3'])
        if survey.get_author(message) == message.from_user.id:
            markup.add(telebot.types.InlineKeyboardButton('View', callback_data='view'),
                       telebot.types.InlineKeyboardButton('Collect', callback_data='collect'),
                       telebot.types.InlineKeyboardButton('Back>>', callback_data='back>>'))
        else:
            ans = answers['COLLECT']
            markup.add(telebot.types.InlineKeyboardButton('Collect', callback_data='collect'),
                       telebot.types.InlineKeyboardButton('Back>>', callback_data='back>>'))
    else:
        ans = answers['NOT_EXIST']
        markup.add(telebot.types.InlineKeyboardButton('Create Survey', callback_data='create survey'))

    bot.send_message(message.chat.id, ans, parse_mode='HTML', reply_markup=markup)
If the bot state for a message/call sender is SURVEY1.

       if an entered survey name exists, switch to SURVEY3 state.
           if the sender is the survey creator, send the assigned answer and
           the 'View, Collect, Back>>' markup.
           else, send the assigned answer and the 'Collect, Back>>' markup.

       else, send the assigned answer and the 'Create Survey' markup.
If the bot state for a message/call sender is SURVEY1.
if an entered survey name exists, switch to SURVEY3 state.
if the sender is the survey creator, send the assigned answer and
the 'View, Collect, Back>>' markup.
else, send the assigned answer and the 'Collect, Back>>' markup.

else, send the assigned answer and the 'Create Survey' markup.
If the bot state for a message / call sender is SURVEY1 . if an entered survey name exists switch to SURVEY3 state . if the sender is the survey creator send the assigned answer and the ' View Collect Back >> ' markup . else send the assigned answer and the ' Collect Back >> ' markup . else send the assigned answer and the ' Create Survey ' markup .
def message_handler(message):
    ans = answers['VIEW']
    markup = telebot.types.InlineKeyboardMarkup()
    if survey.survey_check(message):
        survey.save_survey(message)
        state.save_state(message, state.states['SURVEY3'])
        if survey.get_author(message) == message.from_user.id:
            markup.add(telebot.types.InlineKeyboardButton('View', callback_data='view'),
                       telebot.types.InlineKeyboardButton('Collect', callback_data='collect'),
                       telebot.types.InlineKeyboardButton('Back>>', callback_data='back>>'))
        else:
            ans = answers['COLLECT']
            markup.add(telebot.types.InlineKeyboardButton('Collect', callback_data='collect'),
                       telebot.types.InlineKeyboardButton('Back>>', callback_data='back>>'))
    else:
        ans = answers['NOT_EXIST']
        markup.add(telebot.types.InlineKeyboardButton('Create Survey', callback_data='create survey'))
    bot.send_message(message.chat.id, ans, parse_mode='HTML', reply_markup=markup)
def message_handler ( message ) : ans = answers [ 'VIEW' ] markup = telebot . types . InlineKeyboardMarkup ( ) if survey . survey_check ( message ) : survey . save_survey ( message ) state . save_state ( message , state . states [ 'SURVEY3' ] ) if survey . get_author ( message ) == message . from_user . id : markup . add ( telebot . types . InlineKeyboardButton ( 'View' , callback_data = 'view' ) , telebot . types . InlineKeyboardButton ( 'Collect' , callback_data = 'collect' ) , telebot . types . InlineKeyboardButton ( 'Back>>' , callback_data = 'back>>' ) ) else : ans = answers [ 'COLLECT' ] markup . add ( telebot . types . InlineKeyboardButton ( 'Collect' , callback_data = 'collect' ) , telebot . types . InlineKeyboardButton ( 'Back>>' , callback_data = 'back>>' ) ) else : ans = answers [ 'NOT_EXIST' ] markup . add ( telebot . types . InlineKeyboardButton ( 'Create Survey' , callback_data = 'create survey' ) ) bot . send_message ( message . chat . id , ans , parse_mode = 'HTML' , reply_markup = markup )
If the bot state for a message/call sender is SURVEY1.
If the bot state for a message / call sender is SURVEY1 .
"""If the bot state for a message/call sender is SURVEY1.

       if an entered survey name exists, switch to SURVEY3 state.
           if the sender is the survey creator, send the assigned answer and
           the 'View, Collect, Back>>' markup.
           else, send the assigned answer and the 'Collect, Back>>' markup.

       else, send the assigned answer and the 'Create Survey' markup."""
message