Showing
1 changed file
with
31 additions
and
20 deletions
1 | var express = require('express'); | 1 | var express = require('express'); |
2 | const request = require('request'); | 2 | const request = require('request'); |
3 | const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' | 3 | const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' |
4 | -const TOKEN = 'BDWbq6IfUnMHJrG2k80BvhNly63c/K0TURS26/Kx1EWW82d3o767nHhGfu1G9PbJDye2vg6blpqTUdEU3ATMwN1NEZd0GggujmBbHuUk3iBrzBCTm5LUqHlf4+5lFS8eQb7i9WCcYjdakEt2EAYiZQdB04t89/1O/w1cDnyilFU=' | 4 | +const TOKEN = '' // 라인 토큰 |
5 | const fs = require('fs'); | 5 | const fs = require('fs'); |
6 | const path = require('path'); | 6 | const path = require('path'); |
7 | const HTTPS = require('https'); | 7 | const HTTPS = require('https'); |
8 | -const domain = "www.weatherchatbot.ml" | 8 | +const domain = "www.weatherchatbot.ml" // 도메인 |
9 | const sslport = 23023; | 9 | const sslport = 23023; |
10 | const bodyParser = require('body-parser'); | 10 | const bodyParser = require('body-parser'); |
11 | var app = express(); | 11 | var app = express(); |
12 | const { info } = require('console'); | 12 | const { info } = require('console'); |
13 | 13 | ||
14 | var {PythonShell} = require('python-shell'); | 14 | var {PythonShell} = require('python-shell'); |
15 | + | ||
16 | +var options = { | ||
17 | + | ||
18 | + mode: 'text', | ||
19 | + pythonPath: '', | ||
20 | + pythonOptions: ['-u'], | ||
21 | + scriptPath:'', | ||
22 | + args: ['value1, value2, value3'] | ||
23 | + | ||
24 | +}; | ||
15 | var pyshell = new PythonShell('weather_chat.py'); | 25 | var pyshell = new PythonShell('weather_chat.py'); |
16 | 26 | ||
17 | app.use(bodyParser.json()); | 27 | app.use(bodyParser.json()); |
... | @@ -90,27 +100,28 @@ function chatWeather(replyToken){ | ... | @@ -90,27 +100,28 @@ function chatWeather(replyToken){ |
90 | 100 | ||
91 | pyshell.on('message', function (data) { | 101 | pyshell.on('message', function (data) { |
92 | console.log(data); | 102 | console.log(data); |
103 | + | ||
104 | + request.post( | ||
105 | + { | ||
106 | + url: TARGET_URL, | ||
107 | + headers: { | ||
108 | + 'Authorization': `Bearer ${TOKEN}` | ||
109 | + }, | ||
110 | + json: { | ||
111 | + "replyToken":replyToken, | ||
112 | + "messages":[ | ||
113 | + { | ||
114 | + "type":"text", | ||
115 | + "text": data | ||
116 | + } | ||
117 | + ] | ||
118 | + } | ||
119 | + },(error, response, body) => { | ||
120 | + console.log(body) | ||
121 | + }); | ||
93 | 122 | ||
94 | }); | 123 | }); |
95 | 124 | ||
96 | - request.post( | ||
97 | - { | ||
98 | - url: TARGET_URL, | ||
99 | - headers: { | ||
100 | - 'Authorization': `Bearer ${TOKEN}` | ||
101 | - }, | ||
102 | - json: { | ||
103 | - "replyToken":replyToken, | ||
104 | - "messages":[ | ||
105 | - { | ||
106 | - "type":"text", | ||
107 | - "text": PM | ||
108 | - } | ||
109 | - ] | ||
110 | - } | ||
111 | - },(error, response, body) => { | ||
112 | - console.log(body) | ||
113 | - }); | ||
114 | } | 125 | } |
115 | 126 | ||
116 | function chatWrong(replyToken){ | 127 | function chatWrong(replyToken){ | ... | ... |
-
Please register or login to post a comment