Showing
15 changed files
with
0 additions
and
309 deletions
Experiments/messenger/notify/app.js
deleted
100644 → 0
1 | -// 모듈을 읽어 들입니다. | ||
2 | -const request = require('request');//request라는 모듈로 http를 노드에서 통신할 수 있게 | ||
3 | -// 요청을 위한 상수를 선언합니다: TOKEN은 자신의 것을 입력해주세요. | ||
4 | -const TARGET_URL = 'https://notify-api.line.me/api/notify';//notify api의 주소 | ||
5 | -const TOKEN = 'JSroU3MtclQ9bOZEL93Sn10X0NOcOQH0YenlJ7E6UHE'; | ||
6 | -// 요청합니다. | ||
7 | -request.post( | ||
8 | - { | ||
9 | - url: TARGET_URL, | ||
10 | - headers: { | ||
11 | - 'Authorization': `Bearer ${TOKEN}` | ||
12 | - }, | ||
13 | - form: { | ||
14 | - message: '안녕하세요. LINE Notify 테스트입니다.', | ||
15 | - stickerPackageId: 1, | ||
16 | - stickerId: 1 | ||
17 | - } | ||
18 | - },(error, response, body) => { | ||
19 | - console.log(body) | ||
20 | - }); |
This diff is collapsed. Click to expand it.
Experiments/messenger/push/app.js
deleted
100644 → 0
1 | -const request = require('request'); | ||
2 | -const TARGET_URL = 'https://api.line.me/v2/bot/message/push' | ||
3 | -const MULTI_TARGET_URL = 'https://api.line.me/v2/bot/message/multicast' | ||
4 | -const BROAD_TARGET_URL = 'https://api.line.me/v2/bot/message/broadcast' | ||
5 | -const TOKEN = 'RbPAXRYWub0evg2yyi7oiHytZsZsE0JtbZgRYZNZDU1vjpJkOwGqwh+aKTYKVhVHh6LZOUVZLl84NQQlNWNbXR9hUhPEiLEK0cie4O3OlKUuEe/3wAsjPu7HbRi1zn9BsR3Qr4pcqmiIKP8HRUKvEwdB04t89/1O/w1cDnyilFU=' | ||
6 | -const USER_ID = 'U484f0bb741ba39b93dcba8dbb731860d' | ||
7 | - | ||
8 | -// Single User | ||
9 | -// request.post( | ||
10 | -// { | ||
11 | -// url: TARGET_URL, | ||
12 | -// headers: { | ||
13 | -// 'Authorization': `Bearer ${TOKEN}` | ||
14 | -// }, | ||
15 | -// json: { | ||
16 | -// "to": `${USER_ID}`, | ||
17 | -// "messages":[ | ||
18 | -// { | ||
19 | -// "type":"text", | ||
20 | -// "text":"Hello, user" | ||
21 | -// }, | ||
22 | -// { | ||
23 | -// "type":"text", | ||
24 | -// "text":"May I help you?" | ||
25 | -// } | ||
26 | -// ] | ||
27 | -// } | ||
28 | -// },(error, response, body) => { | ||
29 | -// console.log(body) | ||
30 | -// }); | ||
31 | - | ||
32 | - | ||
33 | -// Multicast User | ||
34 | -// request.post( | ||
35 | -// { | ||
36 | -// url: MULTI_TARGET_URL, | ||
37 | -// headers: { | ||
38 | -// 'Authorization': `Bearer ${TOKEN}` | ||
39 | -// }, | ||
40 | -// json: { | ||
41 | -// "to": [`${USER_ID}`], | ||
42 | -// "messages":[ | ||
43 | -// { | ||
44 | -// "type":"text", | ||
45 | -// "text":"Hello, user" | ||
46 | -// }, | ||
47 | -// { | ||
48 | -// "type":"text", | ||
49 | -// "text":"May I help you?" | ||
50 | -// } | ||
51 | -// ] | ||
52 | -// } | ||
53 | -// },(error, response, body) => { | ||
54 | -// console.log(body) | ||
55 | -// }); | ||
56 | - | ||
57 | - | ||
58 | -// Broadcast | ||
59 | - request.post( | ||
60 | - { | ||
61 | - url: BROAD_TARGET_URL, | ||
62 | - headers: { | ||
63 | - 'Authorization': `Bearer ${TOKEN}` | ||
64 | - }, | ||
65 | - json: { | ||
66 | - "messages":[ | ||
67 | - { | ||
68 | - "type":"text", | ||
69 | - "text":"Hello, user" | ||
70 | - }, | ||
71 | - { | ||
72 | - "type":"text", | ||
73 | - "text":"May I help you?" | ||
74 | - } | ||
75 | - ] | ||
76 | - } | ||
77 | - },(error, response, body) => { | ||
78 | - console.log(body) | ||
79 | - }); | ||
80 | - | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed. Click to expand it.
1 | -{ | ||
2 | - "name": "push", | ||
3 | - "version": "1.0.0", | ||
4 | - "description": "", | ||
5 | - "main": "app.js", | ||
6 | - "scripts": { | ||
7 | - "test": "echo \"Error: no test specified\" && exit 1" | ||
8 | - }, | ||
9 | - "author": "", | ||
10 | - "license": "ISC", | ||
11 | - "dependencies": { | ||
12 | - "request": "^2.88.2", | ||
13 | - "rquest": "^0.1.0" | ||
14 | - } | ||
15 | -} |
Experiments/messenger/reply/app.js
deleted
100644 → 0
1 | -var express = require('express'); | ||
2 | -const request = require('request'); | ||
3 | -const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' | ||
4 | -const TOKEN = 'RbPAXRYWub0evg2yyi7oiHytZsZsE0JtbZgRYZNZDU1vjpJkOwGqwh+aKTYKVhVHh6LZOUVZLl84NQQlNWNbXR9hUhPEiLEK0cie4O3OlKUuEe/3wAsjPu7HbRi1zn9BsR3Qr4pcqmiIKP8HRUKvEwdB04t89/1O/w1cDnyilFU=' | ||
5 | -const fs = require('fs'); | ||
6 | -const path = require('path'); | ||
7 | -const HTTPS = require('https'); | ||
8 | -const domain = "www.osschat.tk" | ||
9 | -const sslport = 23023; | ||
10 | - | ||
11 | -const bodyParser = require('body-parser'); | ||
12 | -var app = express(); | ||
13 | -app.use(bodyParser.json()); | ||
14 | -app.post('/hook', function (req, res) {//hootk으로 사용자가 보낸 메세지가 들어옴 | ||
15 | - | ||
16 | - var eventObj = req.body.events[0]; | ||
17 | - var source = eventObj.source; | ||
18 | - var message = eventObj.message; | ||
19 | - | ||
20 | - // request log // | ||
21 | - console.log('======================', new Date() ,'======================'); | ||
22 | - console.log('[request]', req.body); | ||
23 | - console.log('[request source] ', eventObj.source); | ||
24 | - console.log('[request message]', eventObj.message);//message라는 객체로 사용자의 메세지 확인가능 | ||
25 | - | ||
26 | - | ||
27 | - request.post(//답변을 보냄-위의 reply라는 api쪽으로 | ||
28 | - { | ||
29 | - url: TARGET_URL, | ||
30 | - headers: { | ||
31 | - 'Authorization': `Bearer ${TOKEN}` | ||
32 | - }, | ||
33 | - json: { | ||
34 | - "replyToken":eventObj.replyToken, | ||
35 | - "messages":[ | ||
36 | - { | ||
37 | - "type":"text", | ||
38 | - "text":"Hello, user" | ||
39 | - }, | ||
40 | - { | ||
41 | - "type":"text", | ||
42 | - "text":"May I help you?" | ||
43 | - } | ||
44 | - ] | ||
45 | - } | ||
46 | - },(error, response, body) => { | ||
47 | - console.log(body) | ||
48 | - }); | ||
49 | - | ||
50 | - | ||
51 | - res.sendStatus(200); | ||
52 | -}); | ||
53 | - | ||
54 | -try { | ||
55 | - const option = { | ||
56 | - ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'), | ||
57 | - key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(), | ||
58 | - cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(), | ||
59 | - }; | ||
60 | - | ||
61 | - HTTPS.createServer(option, app).listen(sslport, () => { | ||
62 | - console.log(`[HTTPS] Server is started on port ${sslport}`); | ||
63 | - }); | ||
64 | - } catch (error) { | ||
65 | - console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'); | ||
66 | - console.log(error); | ||
67 | - } | ||
68 | - |
This diff is collapsed. Click to expand it.
1 | -{ | ||
2 | - "name": "reply", | ||
3 | - "version": "1.0.0", | ||
4 | - "description": "", | ||
5 | - "main": "app.js", | ||
6 | - "scripts": { | ||
7 | - "test": "echo \"Error: no test specified\" && exit 1" | ||
8 | - }, | ||
9 | - "author": "", | ||
10 | - "license": "ISC", | ||
11 | - "dependencies": { | ||
12 | - "body-parser": "^1.19.0", | ||
13 | - "express": "^4.17.1", | ||
14 | - "request": "^2.88.2" | ||
15 | - } | ||
16 | -} |
Experiments/messenger/ssl/app.js
deleted
100644 → 0
1 | -const express = require('express'); | ||
2 | -const fs = require('fs'); | ||
3 | -const path = require('path'); | ||
4 | -const HTTPS = require('https'); | ||
5 | - | ||
6 | -const app = express(); | ||
7 | -const domain = "www.osschat.tk" | ||
8 | -const sslport = 23023; | ||
9 | - | ||
10 | - | ||
11 | -try { | ||
12 | - const option = { | ||
13 | - ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'), | ||
14 | - key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(), | ||
15 | - cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(), | ||
16 | - }; | ||
17 | - | ||
18 | - HTTPS.createServer(option, app).listen(sslport, () => { | ||
19 | - console.log(`[HTTPS] Server is started on port ${sslport}`); | ||
20 | - }); | ||
21 | -} catch (error) { | ||
22 | - console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'); | ||
23 | - console.log(error); | ||
24 | -} | ||
25 | - |
This diff is collapsed. Click to expand it.
Experiments/messenger/webhook/app.js
deleted
100644 → 0
1 | -var express = require('express'); | ||
2 | -const bodyParser = require('body-parser'); | ||
3 | -var app = express(); | ||
4 | -const fs = require('fs'); | ||
5 | -const path = require('path'); | ||
6 | -const HTTPS = require('https'); | ||
7 | -const domain = "www.osschat.tk" | ||
8 | -const sslport = 23023; | ||
9 | - | ||
10 | -app.use(bodyParser.json());//json형태로 처리 | ||
11 | - | ||
12 | -app.post('/hook', function (request, response) {//post방식으로 들어온다. | ||
13 | - | ||
14 | - var eventObj = request.body.events[0]; | ||
15 | - var source = eventObj.source; | ||
16 | - var message = eventObj.message; | ||
17 | - | ||
18 | - // request log | ||
19 | - console.log('======================', new Date() ,'======================'); | ||
20 | - console.log('[request]', request.body); | ||
21 | - console.log('[request source] ', eventObj.source); | ||
22 | - console.log('[request message]', eventObj.message); | ||
23 | - | ||
24 | - response.sendStatus(200); | ||
25 | -}); | ||
26 | - | ||
27 | - | ||
28 | -try { | ||
29 | - const option = { | ||
30 | - ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'), | ||
31 | - key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(), | ||
32 | - cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(), | ||
33 | - }; | ||
34 | - | ||
35 | - HTTPS.createServer(option, app).listen(sslport, () => { | ||
36 | - console.log(`[HTTPS] Server is started on port ${sslport}`); | ||
37 | - }); | ||
38 | - } catch (error) { | ||
39 | - console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'); | ||
40 | - console.log(error); | ||
41 | - } | ||
42 | - |
This diff is collapsed. Click to expand it.
1 | -{ | ||
2 | - "name": "webhook", | ||
3 | - "version": "1.0.0", | ||
4 | - "description": "", | ||
5 | - "main": "app.js", | ||
6 | - "scripts": { | ||
7 | - "test": "echo \"Error: no test specified\" && exit 1" | ||
8 | - }, | ||
9 | - "author": "", | ||
10 | - "license": "ISC", | ||
11 | - "dependencies": { | ||
12 | - "body-parser": "^1.19.0", | ||
13 | - "express": "^4.17.1" | ||
14 | - } | ||
15 | -} |
-
Please register or login to post a comment