Дипломная работа: Методология создания экспертной системы для Telegram-Бота

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам

'onpartnership1': onpartnership1,

'onpartnership2': onpartnership2,

'onpartnership3': onpartnership3,

'onpartnership4': onpartnership4,

'onpartnership5': onpartnership5,

'onpartnership6': onpartnership6,

'onpartnership7': onpartnership7,

'onpartnership8': onpartnership8,

'onpartnership9': onpartnership9,

'onpartnership9_no': onpartnership9_no,

'ontradename': ontradename,

'ontradename1': ontradename1,

'ontradename1_no': ontradename1_no,

'ontradename2': ontradename2,

'ontradename2_no': ontradename2_no,

'ontradename3': ontradename3,

'ontradename3_no': ontradename3_no,

'ontradename3_yes': ontradename3_yes,

'onthird1': onthird1, 'onthird1_no': onthird1_no,

'onthird2': onthird2, 'onthird2_no': onthird2_no,

'onthird3': onthird3, 'onthird3_no': onthird3_no,

'onthird4': onthird4, 'onthird_4_16_no': onthird_4_16_no,

'onthird5': onthird5,

'onthird6': onthird6,

'onthird7': onthird7,

'onthird8': onthird8,

'onthird9': onthird9,

'onthird10': onthird10,

'onthird11': onthird11,

'onthird12': onthird12,

'onthird13': onthird13,

'onthird14': onthird14,

'onthird15': onthird15,

'onthird16': onthird16,

'onthird17': onthird17,

'onfourth1': onfourth1, 'onfourth1_no': onfourth1_no,

'onfourth2': onfourth2, 'onfourth3_no': onfourth3_no,

'onfourth3': onfourth3, 'onfourth_4_20_no': onfourth_4_20_no,

'onfourth4': onfourth4,

'onfourth5': onfourth5,

'onfourth6': onfourth6,

'onfourth7': onfourth7,

'onfourth8': onfourth8,

'onfourth9': onfourth9,

'onfourth10': onfourth10,

'onfourth11': onfourth11,

'onfourth12': onfourth12,

'onfourth13': onfourth13,

'onfourth14': onfourth14,

'onfourth15': onfourth15,

'onfourth16': onfourth16,

'onfourth17': onfourth17,

'onfourth18': onfourth18,

'onfourth19': onfourth19,

'onfourth20': onfourth20,

'onfourth21': onfourth21,

'onfifth1': onfifth1, 'onfifth1_no': onfifth1_no,

'onfifth2': onfifth2, 'onfifth2_no': onfifth2_no,

'onfifth3': onfifth3, 'onfifth4_no': onfifth4_no,

'onfifth4': onfifth4, 'onfifth_5_16_no': onfifth_5_16_no,

'onfifth5': onfifth5,

'onfifth6': onfifth6,

'onfifth7': onfifth7,

'onfifth8': onfifth8,

'onfifth9': onfifth9,

'onfifth10': onfifth10,

'onfifth11': onfifth11,

'onfifth12': onfifth12,

'onfifth13': onfifth13,

'onfifth14': onfifth14,

'onfifth15': onfifth15,

'onfifth16': onfifth16,

'onfifth17': onfifth17,

'onsixth1': onsixth1,

'onsixth2': onsixth2, 'onsixth2_yes': onsixth2_yes, 'onsixth2_no': onsixth2_no,

'onsixth3': onsixth3, 'onsixth3_no': onsixth3_no,

}})

return fsm

#Метод для перехода на следующее состояние после набора команды "/start"

def change_state(state):

if state == 'waiting_start':

fsm.gotstart()

#Описываем работу обработчика события "onwaiting_start"

def onwaiting_start(e):

@bot.message_handler(commands=["start"]) #атрибут отвечающие за реагирование на набор команды "/start"

def start(message):

bot.send_message(chat_id=message.chat.id,

text=response_storage.welcome_message) #берем текст сообщения из

# банка всех текстов(response_storage.py)

global chat_id

chat_id = message.chat.id

fsm.current = 'waiting_start' #указываем, что текущее состояние - "waiting_start"

change_state(fsm.current)

#Описываем работу обработчика события "onshow_sections"

def onshow_sections(e):

keyboard = utils.select_keyboard("section-number")

bot.send_message(chat_id=chat_id,

text=response_storage.first_response,

reply_markup=keyboard)

#Дальше пошло описание действий при попадании на каждое конкретное состояние.

def onfirst1(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 1, 'question'),

reply_markup=keyboard)

def onfirst1_no(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 1, 'answer'))

if fsm.current in finals: #если текущее состояние является финальным, то

fsm.go_to_start() #переходим снова в начало к выбору ветки

return

def onfirst2(e):

keyboard = utils.select_keyboard("yes-no-maybe")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 2, 'question'),

reply_markup=keyboard)

def onfirst2_yes(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 2, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def onfirst2_no(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 3, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def onfirst3(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 3, 'question'),

reply_markup=keyboard)

def onfirst3_yes(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 3, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def onfirst4(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 4, 'question'),

reply_markup=keyboard)

def onfirst4_yes(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 3, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def onfirst5(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 5, 'question'),

reply_markup=keyboard)

def onfirst5_yes(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 3, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def onfirst6(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 6, 'question'),

reply_markup=keyboard)

def onfirst6_yes(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 3, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def onfirst6_no(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 4, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def onsecond1(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 1, 'question'),

reply_markup=keyboard)

def onsecond2(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 2, 'question'),

reply_markup=keyboard)

def onsecond3(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 3, 'question'),

reply_markup=keyboard)

def onsecond4(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 4, 'question'),

reply_markup=keyboard)

def onsecond5(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 5, 'question'),

reply_markup=keyboard)

def onsecond6(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 6, 'question'),

reply_markup=keyboard)

def onsecond7(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 7, 'question'),

reply_markup=keyboard)

def onsecond8(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 8, 'question'),

reply_markup=keyboard)

def onsecond9(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 9, 'question'),

reply_markup=keyboard)

def onsecond10(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 10, 'question'),

reply_markup=keyboard)

def onsecond10_no(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 1, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def onpartnership(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 11, 'question'),

reply_markup=keyboard)

def onpartnership1(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 12, 'question'),

reply_markup=keyboard)

def onpartnership2(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 13, 'question'),

reply_markup=keyboard)

def onpartnership3(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 14, 'question'),

reply_markup=keyboard)

def onpartnership4(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 15, 'question'),

reply_markup=keyboard)

def onpartnership5(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 16, 'question'),

reply_markup=keyboard)

def onpartnership6(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 17, 'question'),

reply_markup=keyboard)

def onpartnership7(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 18, 'question'),

reply_markup=keyboard)

def onpartnership8(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 19, 'question'),

reply_markup=keyboard)

def onpartnership9(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 20, 'question'),

reply_markup=keyboard)

def onpartnership9_no(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 2, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def ontradename(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 21, 'question'),

reply_markup=keyboard)

def ontradename1(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 22, 'question'),

reply_markup=keyboard)

def ontradename1_no(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 3, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def ontradename2(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 23, 'question'),

reply_markup=keyboard)

def ontradename2_no(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 3, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def ontradename3(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 24, 'question'),

reply_markup=keyboard)

def ontradename3_no(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 4, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def ontradename3_yes(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(section_number, 5, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def onthird1(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 1, 'question'),

reply_markup=keyboard)

def onthird1_no(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 1, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def onthird2(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 2, 'question'),

reply_markup=keyboard)

def onthird2_no(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 2, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def onthird3(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 3, 'question'),

reply_markup=keyboard)

def onthird3_no(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 3, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def onthird4(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 4, 'question'),

reply_markup=keyboard)

def onthird5(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 5, 'question'),

reply_markup=keyboard)

def onthird6(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 6, 'question'),

reply_markup=keyboard)

def onthird7(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 7, 'question'),

reply_markup=keyboard)

def onthird8(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 8, 'question'),

reply_markup=keyboard)

def onthird9(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 9, 'question'),

reply_markup=keyboard)

def onthird10(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 10, 'question'),

reply_markup=keyboard)

def onthird11(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 11, 'question'),

reply_markup=keyboard)

def onthird12(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 12, 'question'),

reply_markup=keyboard)

def onthird13(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 13, 'question'),

reply_markup=keyboard)

def onthird14(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 14, 'question'),

reply_markup=keyboard)

def onthird15(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 15, 'question'),

reply_markup=keyboard)

def onthird16(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 16, 'question'),

reply_markup=keyboard)

def onthird17(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 4, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def onthird_4_16_no(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(3, 5, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def onfourth1(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 1, 'question'),

reply_markup=keyboard)

def onfourth1_no(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 1, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def onfourth2(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 2, 'question'),

reply_markup=keyboard)

def onfourth2_no(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 1, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def onfourth3(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 3, 'question'),

reply_markup=keyboard)

def onfourth3_no(e):

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 2, 'answer'))

if fsm.current in finals:

fsm.go_to_start()

return

def onfourth4(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 4, 'question'),

reply_markup=keyboard)

def onfourth5(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 5, 'question'),

reply_markup=keyboard)

def onfourth6(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 6, 'question'),

reply_markup=keyboard)

def onfourth7(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 7, 'question'),

reply_markup=keyboard)

def onfourth8(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 8, 'question'),

reply_markup=keyboard)

def onfourth9(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 9, 'question'),

reply_markup=keyboard)

def onfourth10(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 10, 'question'),

reply_markup=keyboard)

def onfourth11(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 11, 'question'),

reply_markup=keyboard)

def onfourth12(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 12, 'question'),

reply_markup=keyboard)

def onfourth13(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 13, 'question'),

reply_markup=keyboard)

def onfourth14(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 14, 'question'),

reply_markup=keyboard)

def onfourth15(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 15, 'question'),

reply_markup=keyboard)

def onfourth16(e):

keyboard = utils.select_keyboard("yes-no")

bot.send_message(chat_id=chat_id,

text=response_storage.select_message(4, 16, 'question'),

reply_markup=keyboard)

def onfourth17(e):

keyboard = utils.select_keyboard("yes-no")