Ubuntu

final fianl

1 var express = require('express');//express 모듈을 사용 1 var express = require('express');//express 모듈을 사용
2 var qs = require('querystring') 2 var qs = require('querystring')
3 const request = require('request');//request 모듈을 사용 3 const request = require('request');//request 모듈을 사용
4 -const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'//라인 api 4 +const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'
5 const fs = require('fs') 5 const fs = require('fs')
6 var NOW = new Date() 6 var NOW = new Date()
7 var YEAR = NOW.getFullYear() 7 var YEAR = NOW.getFullYear()
...@@ -21,7 +21,7 @@ const sslport = 23023; ...@@ -21,7 +21,7 @@ const sslport = 23023;
21 const bodyParser = require('body-parser'); 21 const bodyParser = require('body-parser');
22 var app = express(); 22 var app = express();
23 var premessage='premessage' 23 var premessage='premessage'
24 -var check = false 24 +//var check = false
25 25
26 26
27 app.use(bodyParser.json()); 27 app.use(bodyParser.json());
...@@ -44,10 +44,10 @@ app.post('/hook', function (req, res) { ...@@ -44,10 +44,10 @@ app.post('/hook', function (req, res) {
44 console.log('[request source] ', eventObj.source); 44 console.log('[request source] ', eventObj.source);
45 console.log('[request message]', eventObj.message); 45 console.log('[request message]', eventObj.message);
46 46
47 - if (check == false){ 47 + //if (check == false){
48 - start(eventObj.replyToken, eventObj.message.text)} 48 + start(eventObj.replyToken, eventObj.message.text)//}
49 - else{ 49 + //else{
50 - info(eventObj.replyToken, eventObj.message.text)} 50 + info(eventObj.replyToken, eventObj.message.text)//}
51 51
52 52
53 53
...@@ -58,14 +58,15 @@ app.post('/hook', function (req, res) { ...@@ -58,14 +58,15 @@ app.post('/hook', function (req, res) {
58 58
59 function info (replyToken, message){ 59 function info (replyToken, message){
60 60
61 - if(check==false) 61 + /* if(check==false)
62 { 62 {
63 return 63 return
64 } 64 }
65 + */
65 66
66 67
67 - if(check == true) 68 + // if(check == true)
68 - { 69 + //{
69 var s = message.split(' '); 70 var s = message.split(' ');
70 var m= false 71 var m= false
71 72
...@@ -79,10 +80,10 @@ function info (replyToken, message){ ...@@ -79,10 +80,10 @@ function info (replyToken, message){
79 80
80 } 81 }
81 } 82 }
82 - if(m == false){ 83 + //if(m == false){
83 - return 84 + //return
84 - } 85 + //}
85 - } 86 + // }
86 request.get( 87 request.get(
87 { 88 {
88 url:WEATHER_URL, 89 url:WEATHER_URL,
...@@ -166,13 +167,15 @@ function info (replyToken, message){ ...@@ -166,13 +167,15 @@ function info (replyToken, message){
166 function start (replyToken, message){ 167 function start (replyToken, message){
167 if(message != '시작') 168 if(message != '시작')
168 { 169 {
169 - check = false 170 + //check = false
170 return 171 return
171 } 172 }
172 173
174 + /*
173 if(message == '시작'){ 175 if(message == '시작'){
174 - check= true 176 + //check= true
175 } 177 }
178 + */
176 179
177 var startMessage= '[[특별 혹은 광역시/도]] [[시/구/군/(특별시와 광역시를 제외하고는 시와 구를 붙여주세요)]] [[읍/면/동]]으로 입력해주세요. 예)서울특별시 종로구 사직동, 경기도 용인시기흥구 기흥동, 경기도 안성시 공도읍 ' 180 var startMessage= '[[특별 혹은 광역시/도]] [[시/구/군/(특별시와 광역시를 제외하고는 시와 구를 붙여주세요)]] [[읍/면/동]]으로 입력해주세요. 예)서울특별시 종로구 사직동, 경기도 용인시기흥구 기흥동, 경기도 안성시 공도읍 '
178 request.post( 181 request.post(
......
...@@ -74070,3 +74070,53 @@ undefined ...@@ -74070,3 +74070,53 @@ undefined
74070 [request message] { type: 'text', id: '12206130725410', text: '서울특별시 종로구 사직동' } 74070 [request message] { type: 'text', id: '12206130725410', text: '서울특별시 종로구 사직동' }
74071 undefined 74071 undefined
74072 {} 74072 {}
74073 +====================== 2020-06-25T08:52:11.178Z ======================
74074 +[request] {
74075 + events: [
74076 + {
74077 + type: 'message',
74078 + replyToken: 'abe3448d11764adeb9b1317b4bcdcf5b',
74079 + source: [Object],
74080 + timestamp: 1593075131007,
74081 + mode: 'active',
74082 + message: [Object]
74083 + }
74084 + ],
74085 + destination: 'Ufc379ceefa900fc314514d0d0c0f13cc'
74086 +}
74087 +[request source] { userId: 'U484f0bb741ba39b93dcba8dbb731860d', type: 'user' }
74088 +[request message] { type: 'text', id: '12206825811801', text: '시작' }
74089 +====================== 2020-06-25T08:52:19.066Z ======================
74090 +[request] {
74091 + events: [
74092 + {
74093 + type: 'message',
74094 + replyToken: '0d5f20facc5f4b4aa4b685515b7f52f3',
74095 + source: [Object],
74096 + timestamp: 1593075138919,
74097 + mode: 'active',
74098 + message: [Object]
74099 + }
74100 + ],
74101 + destination: 'Ufc379ceefa900fc314514d0d0c0f13cc'
74102 +}
74103 +[request source] { userId: 'U484f0bb741ba39b93dcba8dbb731860d', type: 'user' }
74104 +[request message] { type: 'text', id: '12206826437003', text: '서울특별시 종로구 사직동' }
74105 +undefined
74106 +{}
74107 +====================== 2020-06-25T08:52:27.366Z ======================
74108 +[request] {
74109 + events: [
74110 + {
74111 + type: 'message',
74112 + replyToken: 'a342aefef6bf46c28cef943b52d48ce4',
74113 + source: [Object],
74114 + timestamp: 1593075147227,
74115 + mode: 'active',
74116 + message: [Object]
74117 + }
74118 + ],
74119 + destination: 'Ufc379ceefa900fc314514d0d0c0f13cc'
74120 +}
74121 +[request source] { userId: 'U484f0bb741ba39b93dcba8dbb731860d', type: 'user' }
74122 +[request message] { type: 'text', id: '12206827103789', text: '시작' }
......