Showing
1 changed file
with
19 additions
and
5 deletions
... | @@ -2,16 +2,30 @@ const express = require('express'); | ... | @@ -2,16 +2,30 @@ const express = require('express'); |
2 | const fs = require('fs'); | 2 | const fs = require('fs'); |
3 | const path = require('path'); | 3 | const path = require('path'); |
4 | const HTTPS = require('https'); | 4 | const HTTPS = require('https'); |
5 | - | ||
6 | -const app = express(); | ||
7 | const domain = "2020105659.osschatbot.cf" | 5 | const domain = "2020105659.osschatbot.cf" |
8 | const sslport = 23023; | 6 | const sslport = 23023; |
9 | 7 | ||
10 | 8 | ||
11 | -app.get('/', function (req, res) { | 9 | +//Configure webhook |
12 | - res.send('Hello World'); | 10 | +const bodyParser = require('body-parser'); |
13 | -}) | 11 | +const app = express(); |
12 | +app.use(bodyParser.json()); | ||
13 | +app.post('/hook', function (request, response) { | ||
14 | + | ||
15 | + var eventObj = request.body.events[0]; | ||
16 | + var source = eventObj.source; | ||
17 | + var message = eventObj.message; | ||
18 | + | ||
19 | + // request log | ||
20 | + console.log('======================', new Date() ,'======================'); | ||
21 | + console.log('[request]', request.body); | ||
22 | + console.log('[request source] ', eventObj.source); | ||
23 | + console.log('[request message]', eventObj.message); | ||
24 | + | ||
25 | + response.sendStatus(200); | ||
26 | +}); | ||
14 | 27 | ||
28 | +//Set SSL | ||
15 | try { | 29 | try { |
16 | const option = { | 30 | const option = { |
17 | ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'), | 31 | ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'), | ... | ... |
-
Please register or login to post a comment