Showing
12 changed files
with
56 additions
and
90 deletions
.vscode/launch.json
deleted
100644 → 0
1 | -{ | ||
2 | - // IntelliSense를 사용하여 가능한 특성에 대해 알아보세요. | ||
3 | - // 기존 특성에 대한 설명을 보려면 가리킵니다. | ||
4 | - // 자세한 내용을 보려면 https://go.microsoft.com/fwlink/?linkid=830387을(를) 방문하세요. | ||
5 | - "version": "0.2.0", | ||
6 | - "configurations": [ | ||
7 | - { | ||
8 | - "type": "pwa-node", | ||
9 | - "request": "launch", | ||
10 | - "name": "Launch Program", | ||
11 | - "skipFiles": [ | ||
12 | - "<node_internals>/**" | ||
13 | - ], | ||
14 | - "program": "${workspaceFolder}/index.js" | ||
15 | - } | ||
16 | - ] | ||
17 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
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' | ||
4 | -const TOKEN = 'Kb1/rQYz4MUhF8XyKQv7z9x0MxVQ5bX/XO8S/yt/1qQEJVAbsEFAaMvXKEOx9Umr7KhivfyDPfZHRRLFPngR0O4ZGWV2VFses8ufPE7uAdvYr4G6keBNAU69nBz5IC71HfbIrUHxXYqD7GfhVwXzpwdB04t89/1O/w1cDnyilFU=' | ||
5 | -const PAPAGO_URL = 'https://openapi.naver.com/v1/papago/n2mt' | ||
6 | -const PAPAGO_ID = 'kwoxKGTi6azBaW9aSVxe' | ||
7 | -const PAPAGO_SECRET = 'svB_MM61oD' | ||
8 | const fs = require('fs'); | 3 | const fs = require('fs'); |
9 | const path = require('path'); | 4 | const path = require('path'); |
10 | const HTTPS = require('https'); | 5 | const HTTPS = require('https'); |
... | @@ -16,7 +11,6 @@ app.use(bodyParser.json()); | ... | @@ -16,7 +11,6 @@ app.use(bodyParser.json()); |
16 | 11 | ||
17 | // var { google } = require('googleapis'); | 12 | // var { google } = require('googleapis'); |
18 | 13 | ||
19 | -/// ---- | ||
20 | var sad = require('./video_sad'); | 14 | var sad = require('./video_sad'); |
21 | 15 | ||
22 | 16 | ||
... | @@ -28,49 +22,26 @@ app.post('/hook', function (req, res) { | ... | @@ -28,49 +22,26 @@ app.post('/hook', function (req, res) { |
28 | 22 | ||
29 | // request log | 23 | // request log |
30 | console.log('======================', new Date() ,'======================'); | 24 | console.log('======================', new Date() ,'======================'); |
31 | - console.log('[request]', req.body); | 25 | + send(eventObj.replyToken, eventObj.message.text); |
32 | - console.log('[request source] ', eventObj.source); | ||
33 | - console.log('[request message]', eventObj.message); | ||
34 | - | ||
35 | - trans(eventObj.replyToken, eventObj.message.text); | ||
36 | - | ||
37 | - | ||
38 | res.sendStatus(200); | 26 | res.sendStatus(200); |
39 | }); | 27 | }); |
40 | -function trans(replyToken, message) { | 28 | +function send(replyToken, message){ |
41 | 29 | ||
42 | request.post( | 30 | request.post( |
43 | - | ||
44 | { | 31 | { |
45 | - url: PAPAGO_URL, | 32 | + body: message |
46 | - headers: { | ||
47 | - 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', | ||
48 | - 'X-Naver-Client-Id': `${PAPAGO_ID}`, | ||
49 | - 'X-Naver-Client-Secret': `${PAPAGO_SECRET}` | ||
50 | - }, | ||
51 | - body: 'source=ko&target=en&text=' + message, | ||
52 | - json: true | ||
53 | }, | 33 | }, |
54 | 34 | ||
55 | - (error, response, body) => { | 35 | + function() { |
56 | - if (!error && response.statusCode == 200) { | 36 | + if (message == "슬픈노래") { |
57 | - // message 가 사용자에게서 입력받은 메시지 내용입니다. sendMessage 는 보낼 메시지 내용입니다. | 37 | + sad.check(message,replyToken); |
58 | - // 위에 PAPAGO API부분은 추후 API를 연동시킬 때 맞춰서 작성하기 쉽도록 템플릿을 남겨놓았습니다. 자세한 정보는 교수님 학습 자료의 experiment의 trans 폴더를 참고하세요. | ||
59 | - // (현재 코드에선 PAPAGO API의 작동 결과는 반영되지 않습니다.) | ||
60 | - //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ | ||
61 | - // var sendMessage; | ||
62 | - | ||
63 | - // -------- | ||
64 | - if (message == "슬픈노래") { | ||
65 | - sad.check(message,replyToken); | ||
66 | - | ||
67 | - } | ||
68 | - else { | ||
69 | - sad.check(message, replyToken); | ||
70 | - } | ||
71 | 38 | ||
72 | } | 39 | } |
73 | - }); | 40 | + else { |
41 | + sad.check(message, replyToken); | ||
42 | + } | ||
43 | + } | ||
44 | + ); | ||
74 | } | 45 | } |
75 | try { | 46 | try { |
76 | const option = { | 47 | const option = { | ... | ... |
static/buttons/1040.jpg
deleted
100644 → 0
62.8 KB
static/imagemap/preview.jpg
deleted
100644 → 0
80.2 KB
static/imagemap/video.mp4
deleted
100644 → 0
No preview for this file type
static/rich/1040
deleted
100644 → 0
No preview for this file type
static/rich/240
deleted
100644 → 0
No preview for this file type
static/rich/300
deleted
100644 → 0
No preview for this file type
static/rich/460
deleted
100644 → 0
No preview for this file type
static/rich/700
deleted
100644 → 0
No preview for this file type
... | @@ -4,51 +4,62 @@ exports.check = function(message,replyToken){ | ... | @@ -4,51 +4,62 @@ exports.check = function(message,replyToken){ |
4 | var ids = ['p5iu1V30myk', 'i-SBnhaZSSU', 'Etfgb6A7hSI', 'IN2mml9xs_s', // 모든 동영상 id를 관리하는 배열 | 4 | var ids = ['p5iu1V30myk', 'i-SBnhaZSSU', 'Etfgb6A7hSI', 'IN2mml9xs_s', // 모든 동영상 id를 관리하는 배열 |
5 | 'tp1uoFAfgHE', 'Qx22TnVVIfU', '3y1QIqR115A', 'VXBI1wt8XII', 'aWMBn2--E0Q', 'HyTbgBlnLCo']; | 5 | 'tp1uoFAfgHE', 'Qx22TnVVIfU', '3y1QIqR115A', 'VXBI1wt8XII', 'aWMBn2--E0Q', 'HyTbgBlnLCo']; |
6 | 6 | ||
7 | - | ||
8 | - | ||
9 | const request = require('request'); | 7 | const request = require('request'); |
10 | const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' | 8 | const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' |
9 | + //라인 고유 토큰 | ||
11 | const TOKEN = 'Kb1/rQYz4MUhF8XyKQv7z9x0MxVQ5bX/XO8S/yt/1qQEJVAbsEFAaMvXKEOx9Umr7KhivfyDPfZHRRLFPngR0O4ZGWV2VFses8ufPE7uAdvYr4G6keBNAU69nBz5IC71HfbIrUHxXYqD7GfhVwXzpwdB04t89/1O/w1cDnyilFU=' | 10 | const TOKEN = 'Kb1/rQYz4MUhF8XyKQv7z9x0MxVQ5bX/XO8S/yt/1qQEJVAbsEFAaMvXKEOx9Umr7KhivfyDPfZHRRLFPngR0O4ZGWV2VFses8ufPE7uAdvYr4G6keBNAU69nBz5IC71HfbIrUHxXYqD7GfhVwXzpwdB04t89/1O/w1cDnyilFU=' |
12 | var { google } = require('googleapis'); | 11 | var { google } = require('googleapis'); |
13 | 12 | ||
14 | var service = google.youtube('v3'); | 13 | var service = google.youtube('v3'); |
15 | - service.videos.list({ | 14 | + service.videos.list |
15 | + ( | ||
16 | + { | ||
16 | key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | 17 | key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', |
17 | part: 'snippet', | 18 | part: 'snippet', |
18 | id: ids[rand_0to9], // 동영상 Id random input | 19 | id: ids[rand_0to9], // 동영상 Id random input |
19 | fields: 'items(snippet(title))' | 20 | fields: 'items(snippet(title))' |
20 | - }, function (err, response) { | 21 | + }, |
21 | - if (err) { | 22 | + function (err, response) |
22 | - console.log('The API returned an error: ', err); | 23 | + { |
23 | - return; | 24 | + if (err) |
24 | - } | 25 | + { |
26 | + console.log('The API returned an error: ', err); | ||
27 | + return; | ||
28 | + } | ||
25 | 29 | ||
26 | - var video = response.data.items; | 30 | + var video = response.data.items; |
27 | - if (video.length == 0) { | 31 | + |
28 | - console.log('검색된 동영상이 없습니다.'); | 32 | + if (video.length == 0) |
29 | - } else { | 33 | + { |
30 | - sendMessage = JSON.stringify(response.data.items[0].snippet.title); | 34 | + console.log('검색된 동영상이 없습니다.'); |
31 | - console.log(sendMessage); | 35 | + } |
32 | - request.post( | 36 | + else |
33 | - { | 37 | + { |
34 | - url: TARGET_URL, | 38 | + sendMessage = JSON.stringify(response.data.items[0].snippet.title); |
35 | - headers: { | 39 | + console.log(sendMessage); |
36 | - 'Authorization': `Bearer ${TOKEN}` | 40 | + request.post( |
37 | - }, | 41 | + { |
38 | - json: { | 42 | + url: TARGET_URL, |
39 | - "replyToken": replyToken, | 43 | + headers: |
40 | - "messages": [ | 44 | + { |
41 | - { | 45 | + 'Authorization': `Bearer ${TOKEN}` |
42 | - "type": "text", | 46 | + }, |
43 | - "text": sendMessage | 47 | + json: |
44 | - } | 48 | + { |
45 | - ] | 49 | + "replyToken": replyToken, |
50 | + "messages": | ||
51 | + [ | ||
52 | + { | ||
53 | + "type": "text", | ||
54 | + "text": sendMessage | ||
55 | + } | ||
56 | + ] | ||
57 | + } | ||
46 | } | 58 | } |
47 | - }, (error, response, body) => { | 59 | + ); |
48 | - console.log(body) | 60 | + } |
49 | - }); | ||
50 | } | 61 | } |
51 | - }) | 62 | + ) |
52 | 63 | ||
53 | 64 | ||
54 | 65 | ... | ... |
-
Please register or login to post a comment