taegwon

app.js final

...@@ -3,16 +3,16 @@ var selected_food = ''; ...@@ -3,16 +3,16 @@ var selected_food = '';
3 var located = ''; 3 var located = '';
4 var count = 0; 4 var count = 0;
5 var real_data = ''; 5 var real_data = '';
6 -var directory = [['food_division_txt_file/korean_food_final.txt','food_division_txt_file/chinese_food_final.txt','food_division_txt_file/japanese_food_final.txt','food_division_txt_file/western_food_final.txt','food_division_txt_file/etc_food_final.txt'],['food_division_txt_file/meat.txt','food_division_txt_file/fish.txt','food_division_txt_file/ect.txt','\0','\0'],['food_division_txt_file/spicy_food_final.txt','food_division_txt_file/not_spicy_food_final.txt','\0','\0','\0'],['food_division_txt_file/water.txt','food_division_txt_file/dry.txt','\0','\0','\0'],['food_division_txt_file/cold_food_final.txt','food_division_txt_file/hot_food_final.txt','\0','\0','\0']]; 6 +var directory = [['CHATBOT/food_division_txt_file/korean_food_final.txt','CHATBOT/food_division_txt_file/chinese_food_final.txt','CHATBOT/food_division_txt_file/japanese_food_final.txt','CHATBOT/food_division_txt_file/western_food_final.txt','CHATBOT/food_division_txt_file/etc_food_final.txt'],['CHATBOT/food_division_txt_file/meat.txt','CHATBOT/food_division_txt_file/fish.txt','CHATBOT/food_division_txt_file/ect.txt','\0','\0'],['CHATBOT/food_division_txt_file/spicy_food_final.txt','CHATBOT/food_division_txt_file/not_spicy_food_final.txt','\0','\0','\0'],['CHATBOT/food_division_txt_file/water.txt','CHATBOT/food_division_txt_file/dry.txt','\0','\0','\0'],['CHATBOT/food_division_txt_file/cold_food_final.txt','CHATBOT/food_division_txt_file/hot_food_final.txt','\0','\0','\0']];
7 var save_file_name = ['fin_1.txt','fin_2.txt','fin_3.txt','fin.txt']; 7 var save_file_name = ['fin_1.txt','fin_2.txt','fin_3.txt','fin.txt'];
8 var choosen = new Array(); 8 var choosen = new Array();
9 var express = require('express'); 9 var express = require('express');
10 const request = require('request'); 10 const request = require('request');
11 const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' 11 const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'
12 -const TOKEN = 'Ur8nbk2bQAc9KavLSSJv0uzlKWCxCBnOJOKyqbRS1mMHWgJlEOPfb7v+X1DDEHocUmhU7KnPFN+KHt5S3SYd5QmF42aTeQpW2gDVTjyqty1Tn+p6QqEhI/uSz659PBHwczEYn0Plx+akfCNHDPJRpAdB04t89/1O/w1cDnyilFU=' 12 +const TOKEN = 'TOKEN'
13 -const PAPAGO_URL = 'https://openapi.naver.com/v1/papago/n2mt' 13 +const PAPAGO_URL = 'PAPAGO URL'
14 -const PAPAGO_ID = '1Z83W3lUGLqnNbrDAk8A' 14 +const PAPAGO_ID = 'PAPAGO ID'
15 -const PAPAGO_SECRET = 'oDlgYoi4LO' 15 +const PAPAGO_SECRET = 'PAPAGO SECRET'
16 var fs = require('fs'); 16 var fs = require('fs');
17 const path = require('path'); 17 const path = require('path');
18 const HTTPS = require('https'); 18 const HTTPS = require('https');
...@@ -156,7 +156,7 @@ async function start_msg(replyToken, message) { ...@@ -156,7 +156,7 @@ async function start_msg(replyToken, message) {
156 'X-Naver-Client-Id': `${PAPAGO_ID}`, 156 'X-Naver-Client-Id': `${PAPAGO_ID}`,
157 'X-Naver-Client-Secret': `${PAPAGO_SECRET}` 157 'X-Naver-Client-Secret': `${PAPAGO_SECRET}`
158 }, 158 },
159 - body: 'source=en&target=ko&text=' + "Hi This is Menu recommend Chatbot! If you follow the instructions, I will recommend the menu. 진행하시겠습니까?(y/n)", 159 + body: 'source=en&target=ko&text=' + "Hi! This is Menu recommend Chatbot! If you follow the instructions, I will recommend the menu. 진행하시겠습니까? (y/n)",
160 json: true 160 json: true
161 }, (error, response, body) => { 161 }, (error, response, body) => {
162 if (!error && response.statusCode == 200) { 162 if (!error && response.statusCode == 200) {
...@@ -193,7 +193,7 @@ async function opt_1(replyToken, message) { ...@@ -193,7 +193,7 @@ async function opt_1(replyToken, message) {
193 'X-Naver-Client-Id': `${PAPAGO_ID}`, 193 'X-Naver-Client-Id': `${PAPAGO_ID}`,
194 'X-Naver-Client-Secret': `${PAPAGO_SECRET}` 194 'X-Naver-Client-Secret': `${PAPAGO_SECRET}`
195 }, 195 },
196 - body: 'source=en&target=ko&text=' + "1.Korean cuisine 2.Chinese food 3.Japanese food 4.Western food 5.Guitar", 196 + body: 'source=en&target=ko&text=' + "1.한식 2.중식 3.Japanese food 4.Western food 5.Guitar",
197 json: true 197 json: true
198 }, (error, response, body) => { 198 }, (error, response, body) => {
199 if (!error && response.statusCode == 200) { 199 if (!error && response.statusCode == 200) {
...@@ -383,7 +383,7 @@ async function Rmx_comment(replyToken) ...@@ -383,7 +383,7 @@ async function Rmx_comment(replyToken)
383 "messages": [ 383 "messages": [
384 { 384 {
385 "type": "text", 385 "type": "text",
386 - "text": "아무키나 입력해 추천 음식 보기." 386 + "text": "아무 키나 입력해 추천 음식 보기."
387 } 387 }
388 ] 388 ]
389 } 389 }
...@@ -560,7 +560,7 @@ async function intersection() ...@@ -560,7 +560,7 @@ async function intersection()
560 { 560 {
561 const spawn = await require('child_process').spawn; 561 const spawn = await require('child_process').spawn;
562 for (var i = 0, j = 0; i < 3; i += 2, j++) { 562 for (var i = 0, j = 0; i < 3; i += 2, j++) {
563 - var result = await spawn('python', ['fileread_practice.py', directory[i][Number(choosen[i]) - 1], directory[i + 1][Number(choosen[i + 1]) - 1], save_file_name[j]]); 563 + var result = await spawn('python', ['/home/ec2-user/menu_recommand_webpage/CHATBOT/fileread_practice.py', directory[i][Number(choosen[i]) - 1], directory[i + 1][Number(choosen[i + 1]) - 1], save_file_name[j]]);
564 await result.stdout.on('data', function (data) { 564 await result.stdout.on('data', function (data) {
565 console.log(data.toString()); 565 console.log(data.toString());
566 }); 566 });
...@@ -568,14 +568,14 @@ async function intersection() ...@@ -568,14 +568,14 @@ async function intersection()
568 console.log(data.toString()); 568 console.log(data.toString());
569 }); 569 });
570 } 570 }
571 - result = await spawn('python', ['fileread_practice.py', save_file_name[0], save_file_name[1], save_file_name[2]]); 571 + result = await spawn('python', ['/home/ec2-user/menu_recommand_webpage/CHATBOT/fileread_practice.py', save_file_name[0], save_file_name[1], save_file_name[2]]);
572 result.stdout.on('data', function (data) { 572 result.stdout.on('data', function (data) {
573 console.log(data.toString()); 573 console.log(data.toString());
574 }); 574 });
575 await result.stderr.on('data', function (data) { 575 await result.stderr.on('data', function (data) {
576 console.log(data.toString()); 576 console.log(data.toString());
577 }); 577 });
578 - result = await spawn('python', ['fileread_practice.py', save_file_name[2], directory[4][Number(choosen[4]) - 1], save_file_name[3]]); 578 + result = await spawn('python', ['/home/ec2-user/menu_recommand_webpage/CHATBOT/fileread_practice.py', save_file_name[2], directory[4][Number(choosen[4]) - 1], save_file_name[3]]);
579 result.stdout.on('data', function (data) { 579 result.stdout.on('data', function (data) {
580 console.log(data.toString()); 580 console.log(data.toString());
581 }); 581 });
......