hubot 11.1.9 → 11.2.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/README.md +2 -0
- package/package.json +1 -1
- package/src/adapters/Shell.mjs +15 -4
package/README.md
CHANGED
|
@@ -39,6 +39,8 @@ See the [LICENSE](LICENSE.md) file for license rights and limitations (MIT).
|
|
|
39
39
|
|
|
40
40
|
# Hubot History
|
|
41
41
|
|
|
42
|
+
[Say hello to Hubot](https://github.blog/2011-10-25-say-hello-to-hubot/)
|
|
43
|
+
|
|
42
44
|
[Cartoon with Hubot](https://www.youtube.com/watch?v=vq2jYFZVMDA&t=129s)
|
|
43
45
|
|
|
44
46
|
[The Most Important Startup's Hardest Worker Isn't a Person](https://www.wired.com/2015/10/the-most-important-startups-hardest-worker-isnt-a-person/)
|
package/package.json
CHANGED
package/src/adapters/Shell.mjs
CHANGED
|
@@ -51,9 +51,10 @@ class Shell extends Adapter {
|
|
|
51
51
|
if (stats.size > historySize) {
|
|
52
52
|
fs.unlinkSync(historyPath)
|
|
53
53
|
}
|
|
54
|
+
|
|
54
55
|
this.#rl = readline.createInterface({
|
|
55
|
-
input: process.stdin,
|
|
56
|
-
output: process.stdout,
|
|
56
|
+
input: this.robot.stdin ?? process.stdin,
|
|
57
|
+
output: this.robot.stdout ?? process.stdout,
|
|
57
58
|
prompt: `${this.robot.name ?? this.robot.alias}> `,
|
|
58
59
|
completer
|
|
59
60
|
})
|
|
@@ -84,12 +85,22 @@ class Shell extends Adapter {
|
|
|
84
85
|
}
|
|
85
86
|
const userName = process.env.HUBOT_SHELL_USER_NAME || 'Shell'
|
|
86
87
|
const user = this.robot.brain.userForId(userId, { name: userName, room: 'Shell' })
|
|
87
|
-
|
|
88
|
+
const message = new TextMessage(user, input, 'messageId')
|
|
89
|
+
if (!message.text.startsWith(this.robot.name) && !message.text.startsWith(this.robot.alias)) {
|
|
90
|
+
message.text = `${this.robot.name} ${message.text}`
|
|
91
|
+
}
|
|
92
|
+
await this.receive(message)
|
|
88
93
|
this.#rl.prompt()
|
|
89
94
|
})
|
|
95
|
+
|
|
90
96
|
this.#rl.on('history', async (history) => {
|
|
91
|
-
|
|
97
|
+
if (history.length === 0) return
|
|
98
|
+
await fs.promises.appendFile(historyPath, `${history[0]}\n`)
|
|
92
99
|
})
|
|
100
|
+
|
|
101
|
+
const existingHistory = (await fs.promises.readFile(historyPath, 'utf8')).split('\n')
|
|
102
|
+
existingHistory.forEach(line => this.#rl.history.push(line))
|
|
103
|
+
|
|
93
104
|
try {
|
|
94
105
|
this.#rl.prompt()
|
|
95
106
|
this.emit('connected', this)
|