(ctx: AdapterContext)
| 71 | } |
| 72 | |
| 73 | async start(ctx: AdapterContext): Promise<void> { |
| 74 | this.agent = ctx.agent; |
| 75 | this.rootDir = ctx.rootDir; |
| 76 | this.ipcBroadcaster = ctx.ipcBroadcaster ?? null; |
| 77 | |
| 78 | this.app = new App({ |
| 79 | token: this.options.botToken, |
| 80 | appToken: this.options.appToken, |
| 81 | socketMode: true, |
| 82 | ignoreSelf: true, |
| 83 | logLevel: LogLevel.INFO, |
| 84 | }); |
| 85 | |
| 86 | const auth = await this.app.client.auth.test({ |
| 87 | token: this.options.botToken, |
| 88 | }); |
| 89 | this.botUserId = |
| 90 | typeof auth.user_id === "string" ? auth.user_id : null; |
| 91 | |
| 92 | this.registerListeners(this.app); |
| 93 | await this.app.start(); |
| 94 | |
| 95 | const identity = this.botUserId ? `<@${this.botUserId}>` : "Slack bot"; |
| 96 | console.log(`[SlackAdapter] Started as ${identity}`); |
| 97 | } |
| 98 | |
| 99 | async stop(): Promise<void> { |
| 100 | if (this.app) { |
no test coverage detected