hubot 9.1.0 → 9.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/README.md +7 -5
- package/package.json +4 -2
- package/sfab-hooks/SfabHook.mjs +11 -0
- package/src/robot.js +34 -28
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
1
3
|

|
|
2
4
|

|
|
3
5
|

|
|
@@ -5,11 +7,11 @@
|
|
|
5
7
|
# Hubot
|
|
6
8
|
|
|
7
9
|
Hubot is a framework to build chat bots, modeled after GitHub's Campfire bot of the same name, hubot.
|
|
8
|
-
He's pretty cool. He's [extendable with scripts](
|
|
9
|
-
on [many different chat services](https://
|
|
10
|
+
He's pretty cool. He's [extendable with scripts](https://hubotio.github.io/hubot/docs#scripts) and can work
|
|
11
|
+
on [many different chat services](https://hubotio.github.io/hubot/adapters.html).
|
|
10
12
|
|
|
11
13
|
This repository provides a library that's distributed by `npm` that you
|
|
12
|
-
use for building your own bots. See the [documentation](
|
|
14
|
+
use for building your own bots. See the [documentation](https://hubotio.github.io/hubot/docs.html)
|
|
13
15
|
for details on getting up and running with your very own robot friend.
|
|
14
16
|
|
|
15
17
|
In most cases, you'll probably never have to hack on this repo directly if you
|
|
@@ -17,9 +19,9 @@ are building your own bot. But if you do, check out [CONTRIBUTING.md](CONTRIBUTI
|
|
|
17
19
|
|
|
18
20
|
# Create your own Hubot instance
|
|
19
21
|
|
|
22
|
+
This will create a directory called `myhubot` in the current working directory.
|
|
23
|
+
|
|
20
24
|
```sh
|
|
21
|
-
mkdir myhubot
|
|
22
|
-
cd myhubot
|
|
23
25
|
npx hubot --create myhubot --adapter @hubot-friends/hubot-slack
|
|
24
26
|
```
|
|
25
27
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hubot",
|
|
3
|
-
"version": "9.1.
|
|
3
|
+
"version": "9.1.1",
|
|
4
4
|
"author": "hubot",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github",
|
|
@@ -40,7 +40,9 @@
|
|
|
40
40
|
"pretest": "standard",
|
|
41
41
|
"test": "node --test",
|
|
42
42
|
"test:smoke": "node src/**/*.js",
|
|
43
|
-
"test:e2e": "bin/e2e-test.sh"
|
|
43
|
+
"test:e2e": "bin/e2e-test.sh",
|
|
44
|
+
"build:local": "npx @hubot-friends/sfab --folder ./docs --destination ./_site --verbose --serve /hubot/ --watch-path ./docs --scripts ./sfab-hooks",
|
|
45
|
+
"build": "npx @hubot-friends/sfab --folder ./docs --destination ./_site --verbose --scripts ./sfab-hooks"
|
|
44
46
|
},
|
|
45
47
|
"release": {
|
|
46
48
|
"branches": [
|
package/src/robot.js
CHANGED
|
@@ -37,6 +37,7 @@ class Robot {
|
|
|
37
37
|
this.brain = new Brain(this)
|
|
38
38
|
this.alias = alias
|
|
39
39
|
this.adapter = null
|
|
40
|
+
this.shouldEnableHttpd = httpd ?? true
|
|
40
41
|
this.datastore = null
|
|
41
42
|
this.Response = Response
|
|
42
43
|
this.commands = []
|
|
@@ -55,18 +56,13 @@ class Robot {
|
|
|
55
56
|
this.globalHttpOptions = {}
|
|
56
57
|
|
|
57
58
|
this.parseVersion()
|
|
58
|
-
if (httpd) {
|
|
59
|
-
this.setupExpress()
|
|
60
|
-
} else {
|
|
61
|
-
this.setupNullRouter()
|
|
62
|
-
}
|
|
63
|
-
|
|
64
59
|
this.adapterName = adapter ?? 'shell'
|
|
65
60
|
this.errorHandlers = []
|
|
66
61
|
|
|
67
62
|
this.on('error', (err, res) => {
|
|
68
63
|
return this.invokeErrorHandlers(err, res)
|
|
69
64
|
})
|
|
65
|
+
this.on('listening', this.herokuKeepalive.bind(this))
|
|
70
66
|
}
|
|
71
67
|
|
|
72
68
|
// Public: Adds a custom Listener with the provided matcher, options, and
|
|
@@ -407,8 +403,8 @@ class Robot {
|
|
|
407
403
|
|
|
408
404
|
// Setup the Express server's defaults.
|
|
409
405
|
//
|
|
410
|
-
// Returns
|
|
411
|
-
setupExpress () {
|
|
406
|
+
// Returns Server.
|
|
407
|
+
async setupExpress () {
|
|
412
408
|
const user = process.env.EXPRESS_USER
|
|
413
409
|
const pass = process.env.EXPRESS_PASSWORD
|
|
414
410
|
const stat = process.env.EXPRESS_STATIC
|
|
@@ -444,27 +440,18 @@ class Robot {
|
|
|
444
440
|
if (stat) {
|
|
445
441
|
app.use(express.static(stat))
|
|
446
442
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
throw error
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
let herokuUrl = process.env.HEROKU_URL
|
|
457
|
-
|
|
458
|
-
if (herokuUrl) {
|
|
459
|
-
if (!/\/$/.test(herokuUrl)) {
|
|
460
|
-
herokuUrl += '/'
|
|
461
|
-
}
|
|
462
|
-
this.pingIntervalId = setInterval(() => {
|
|
463
|
-
HttpClient.create(`${herokuUrl}hubot/ping`).post()((_err, res, body) => {
|
|
464
|
-
this.logger.info('keep alive ping!')
|
|
443
|
+
const p = new Promise((resolve, reject) => {
|
|
444
|
+
try {
|
|
445
|
+
this.server = app.listen(port, address, () => {
|
|
446
|
+
this.router = app
|
|
447
|
+
this.emit('listening', this.server)
|
|
448
|
+
resolve(this.server)
|
|
465
449
|
})
|
|
466
|
-
}
|
|
467
|
-
|
|
450
|
+
} catch (err) {
|
|
451
|
+
reject(err)
|
|
452
|
+
}
|
|
453
|
+
})
|
|
454
|
+
return p
|
|
468
455
|
}
|
|
469
456
|
|
|
470
457
|
// Setup an empty router object
|
|
@@ -645,6 +632,11 @@ class Robot {
|
|
|
645
632
|
//
|
|
646
633
|
// Returns whatever the adapter returns.
|
|
647
634
|
async run () {
|
|
635
|
+
if (this.shouldEnableHttpd) {
|
|
636
|
+
await this.setupExpress()
|
|
637
|
+
} else {
|
|
638
|
+
this.setupNullRouter()
|
|
639
|
+
}
|
|
648
640
|
this.emit('running')
|
|
649
641
|
|
|
650
642
|
return await this.adapter.run()
|
|
@@ -712,6 +704,20 @@ class Robot {
|
|
|
712
704
|
|
|
713
705
|
return HttpClient.create(url, httpOptions).header('User-Agent', `Hubot/${this.version}`)
|
|
714
706
|
}
|
|
707
|
+
|
|
708
|
+
herokuKeepalive (server) {
|
|
709
|
+
let herokuUrl = process.env.HEROKU_URL
|
|
710
|
+
if (herokuUrl) {
|
|
711
|
+
if (!/\/$/.test(herokuUrl)) {
|
|
712
|
+
herokuUrl += '/'
|
|
713
|
+
}
|
|
714
|
+
this.pingIntervalId = setInterval(() => {
|
|
715
|
+
HttpClient.create(`${herokuUrl}hubot/ping`).post()((_err, res, body) => {
|
|
716
|
+
this.logger.info('keep alive ping!')
|
|
717
|
+
})
|
|
718
|
+
}, 5 * 60 * 1000)
|
|
719
|
+
}
|
|
720
|
+
}
|
|
715
721
|
}
|
|
716
722
|
|
|
717
723
|
module.exports = Robot
|