@hubot-friends/hubot-slack 3.3.0 → 3.4.0
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/configuration/Configure.mjs +8 -0
- package/package.json +2 -2
- package/src/Bot.mjs +3 -1
- package/test/ProxyAgent.mjs +44 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// If you want to use this, you have to `npm install proxy-agent` and uncomment the import statement below
|
|
2
|
+
// import { ProxyAgent } from 'proxy-agent'
|
|
3
|
+
export default async robot => {
|
|
4
|
+
robot.logger.info(`This is an example showing how to configure a proxy for the Slack Adapter's Web Client to use.`)
|
|
5
|
+
robot.config = {
|
|
6
|
+
// agent: new ProxyAgent(),
|
|
7
|
+
}
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubot-friends/hubot-slack",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "A new Slack adapter for Hubot",
|
|
5
5
|
"homepage": "https://github.com/hubot-friends/hubot-slack#readme",
|
|
6
6
|
"main": "./index.mjs",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@slack/web-api": "^6.11.2"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"hubot": "^11.
|
|
32
|
+
"hubot": "^11.6.0"
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
|
35
35
|
"node": ">= 18"
|
package/src/Bot.mjs
CHANGED
|
@@ -179,7 +179,9 @@ class SlackBot extends Adapter {
|
|
|
179
179
|
super(robot);
|
|
180
180
|
this.options = options;
|
|
181
181
|
this.robot.logger.info(`hubot-slack adapter v${pkg.version}`);
|
|
182
|
-
this.
|
|
182
|
+
this.socket = new SocketModeClient({ appToken: options.appToken, ...options.socketModeOptions });
|
|
183
|
+
this.web = new WebClient(options.botToken, { agent: robot.config?.agent ?? undefined, maxRequestConcurrency: 1, logLevel: 'error'});
|
|
184
|
+
this.client = new SlackClient(this.options, this.robot, this.socket, this.web);
|
|
183
185
|
this.seenMessages = new Set();
|
|
184
186
|
}
|
|
185
187
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { describe, it, beforeEach } from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
import { SlackBot, SlackClient } from '../src/Bot.mjs'
|
|
4
|
+
import hubotSlackMock from '../index.mjs'
|
|
5
|
+
import { loadBot, Robot } from 'hubot'
|
|
6
|
+
import { SlackTextMessage, ReactionMessage, FileSharedMessage } from '../src/Message.mjs'
|
|
7
|
+
import EventEmitter from 'node:events'
|
|
8
|
+
import { WebClient } from '@slack/web-api'
|
|
9
|
+
|
|
10
|
+
class SocketModeClientMock extends EventEmitter{
|
|
11
|
+
constructor() {
|
|
12
|
+
super()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
send() {
|
|
16
|
+
return Promise.resolve()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class WebClientMock extends WebClient{
|
|
21
|
+
constructor(token, options) {
|
|
22
|
+
super(token, options)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class ProxyAgent {
|
|
27
|
+
constructor() {
|
|
28
|
+
this.type = 'proxy'
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe('Proxy support', () => {
|
|
33
|
+
it('Pass through an agent optiont to the WebClient', async () => {
|
|
34
|
+
const robot = new Robot('TestBot', 'testbot', 'testbot_alias')
|
|
35
|
+
robot.config = {
|
|
36
|
+
agent: new ProxyAgent()
|
|
37
|
+
}
|
|
38
|
+
const sut = new SlackClient({}, robot, new SocketModeClientMock(), new WebClientMock(null, {
|
|
39
|
+
agent: robot.config.agent
|
|
40
|
+
}))
|
|
41
|
+
assert.equal(robot.agent, sut.web.agent)
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
})
|