({
event,
body,
context,
client,
}: any)
| 200 | await this.runAgent(channelId, userText, client, route, attachments); |
| 201 | } |
| 202 | |
| 203 | private async handleMention({ |
| 204 | event, |
| 205 | body, |
| 206 | context, |
| 207 | client, |
| 208 | }: any): Promise<void> { |
| 209 | if (!this.agent || !this.isSupportedMentionEvent(event)) { |
| 210 | return; |
| 211 | } |
| 212 | |
| 213 | const teamId = this.getTeamId(body, context); |
| 214 | const threadTs = event.thread_ts || event.ts; |
| 215 | const channelId = |
| 216 | `slack-thread-${teamId}-${event.channel}-${threadTs}`; |
| 217 | const route: SlackRoute = { |
| 218 | channel: event.channel, |
| 219 | threadTs, |
| 220 | }; |
| 221 | |
| 222 | this.lastThreadByChannel.set( |
| 223 | this.getChannelKey(teamId, event.channel), |
| 224 | threadTs, |
| 225 | ); |
| 226 | |
| 227 | const text = this.stripBotMention(event.text || "").trim(); |
| 228 | this.ipcBroadcaster?.broadcastInbound( |
| 229 | channelId, |
| 230 | "slack", |
| 231 | { |
| 232 | id: String(event.user || ""), |
| 233 | username: String(event.user || ""), |
| 234 | }, |
| 235 | text, |
| 236 | ); |
| 237 | |
| 238 | // Extract file attachments |
| 239 | const attachments = await this.extractSlackFiles(event, channelId, client); |
| 240 | |
| 241 | if (!text && attachments.length === 0) { |
| 242 | await this.sendSafe( |
| 243 | client, |
| 244 | route, |
| 245 | "Mention me with a message, or use `/clear` or `/new` to reset this thread.", |
| 246 | ); |
| 247 | return; |
| 248 | } |
| 249 | |
| 250 | await this.tryAckReaction(client, event); |
| 251 | |
| 252 | if (text && await this.tryHandleInlineCommand(text, channelId, client, route)) { |
| 253 | return; |
| 254 | } |
| 255 | |
| 256 | const userText = text || "(User sent an attachment)"; |
| 257 | await this.runAgent(channelId, userText, client, route, attachments); |
| 258 | } |
| 259 |
no test coverage detected