clisbot 0.1.28 → 0.1.30
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/dist/main.js +42 -10
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -69361,7 +69361,7 @@ function isSlackCommandLikeMessage(params) {
|
|
|
69361
69361
|
}) !== null;
|
|
69362
69362
|
}
|
|
69363
69363
|
function renderSlackRouteChoiceMessage(params) {
|
|
69364
|
-
const
|
|
69364
|
+
const botReference = params.botLabel?.trim() ? `mention this bot (${params.botLabel.trim()})` : "mention this bot";
|
|
69365
69365
|
return [
|
|
69366
69366
|
"clisbot: this Slack channel is not configured yet.",
|
|
69367
69367
|
"",
|
|
@@ -69369,19 +69369,34 @@ function renderSlackRouteChoiceMessage(params) {
|
|
|
69369
69369
|
`- \`clisbot channels add slack-channel ${params.channelId}\``,
|
|
69370
69370
|
`- \`clisbot channels add slack-channel ${params.channelId} --agent <id>\``,
|
|
69371
69371
|
"",
|
|
69372
|
-
`After that,
|
|
69372
|
+
`After that, ${botReference} and send \`\\start\` or \`\\status\` here.`
|
|
69373
69373
|
].join(`
|
|
69374
69374
|
`);
|
|
69375
69375
|
}
|
|
69376
69376
|
function renderSlackMentionRequiredMessage(botLabel) {
|
|
69377
|
-
const
|
|
69377
|
+
const botReference = botLabel?.trim() ? `mention this bot (${botLabel.trim()})` : "mention this bot";
|
|
69378
69378
|
return [
|
|
69379
69379
|
"clisbot: this Slack channel requires a bot mention for new commands.",
|
|
69380
|
-
`Try
|
|
69380
|
+
`Try ${botReference} and send \`\\start\` or \`\\status\` here.`,
|
|
69381
69381
|
"After the bot replies in a thread, normal follow-up messages there can continue according to the follow-up policy."
|
|
69382
69382
|
].join(`
|
|
69383
69383
|
`);
|
|
69384
69384
|
}
|
|
69385
|
+
function shouldSendSlackMentionRequiredGuidance(params) {
|
|
69386
|
+
return params.conversationKind === "dm" && params.isCommandLike;
|
|
69387
|
+
}
|
|
69388
|
+
function shouldGuideUnroutedSlackEvent(params) {
|
|
69389
|
+
if (params.isBotOriginated) {
|
|
69390
|
+
return false;
|
|
69391
|
+
}
|
|
69392
|
+
if (!params.isCommandLike) {
|
|
69393
|
+
return false;
|
|
69394
|
+
}
|
|
69395
|
+
if (params.conversationKind === "dm") {
|
|
69396
|
+
return true;
|
|
69397
|
+
}
|
|
69398
|
+
return params.wasMentioned;
|
|
69399
|
+
}
|
|
69385
69400
|
async function sendSlackGuidanceOnce(params) {
|
|
69386
69401
|
if (!params.eventId) {
|
|
69387
69402
|
await params.send();
|
|
@@ -70134,11 +70149,15 @@ class SlackSocketService {
|
|
|
70134
70149
|
directReplyToBot: isImplicitBotThreadReply(event, this.botUserId)
|
|
70135
70150
|
});
|
|
70136
70151
|
if (requiresMention && !wasMentioned) {
|
|
70137
|
-
|
|
70152
|
+
const isCommandLike = isSlackCommandLikeMessage({
|
|
70138
70153
|
text: event.text ?? "",
|
|
70139
70154
|
botUserId: this.botUserId,
|
|
70140
70155
|
botUsername: this.botLabel,
|
|
70141
70156
|
commandPrefixes: params.route.commandPrefixes
|
|
70157
|
+
});
|
|
70158
|
+
if (shouldSendSlackMentionRequiredGuidance({
|
|
70159
|
+
conversationKind: params.conversationKind,
|
|
70160
|
+
isCommandLike
|
|
70142
70161
|
})) {
|
|
70143
70162
|
try {
|
|
70144
70163
|
await postSlackText(this.app.client, {
|
|
@@ -70155,6 +70174,7 @@ class SlackSocketService {
|
|
|
70155
70174
|
channelId,
|
|
70156
70175
|
requiresMention,
|
|
70157
70176
|
explicitMention,
|
|
70177
|
+
isCommandLike,
|
|
70158
70178
|
effectiveFollowUpMode
|
|
70159
70179
|
});
|
|
70160
70180
|
await this.processedEventsStore.markCompleted(eventId);
|
|
@@ -70341,6 +70361,13 @@ class SlackSocketService {
|
|
|
70341
70361
|
const resolvedRoute = resolveSlackConversationRoute(this.loadedConfig, normalizedEvent, { accountId: this.accountId });
|
|
70342
70362
|
const route = resolvedRoute.route;
|
|
70343
70363
|
if (!route) {
|
|
70364
|
+
if (isBotOriginatedSlackEvent(normalizedEvent) && !this.loadedConfig.raw.channels.slack.allowBots) {
|
|
70365
|
+
debugSlackEvent("drop-unrouted-bot-mention", {
|
|
70366
|
+
eventId: body.event_id,
|
|
70367
|
+
allowBots: this.loadedConfig.raw.channels.slack.allowBots
|
|
70368
|
+
});
|
|
70369
|
+
return;
|
|
70370
|
+
}
|
|
70344
70371
|
try {
|
|
70345
70372
|
await this.maybeGuideUnroutedSlackEvent({
|
|
70346
70373
|
eventId: body.event_id,
|
|
@@ -70376,11 +70403,16 @@ class SlackSocketService {
|
|
|
70376
70403
|
const resolvedRoute = resolveSlackConversationRoute(this.loadedConfig, normalizedEvent, { accountId: this.accountId });
|
|
70377
70404
|
const route = resolvedRoute.route;
|
|
70378
70405
|
if (!route) {
|
|
70379
|
-
const shouldGuide =
|
|
70380
|
-
|
|
70381
|
-
|
|
70382
|
-
|
|
70383
|
-
|
|
70406
|
+
const shouldGuide = shouldGuideUnroutedSlackEvent({
|
|
70407
|
+
conversationKind: resolvedRoute.conversationKind,
|
|
70408
|
+
isCommandLike: isSlackCommandLikeMessage({
|
|
70409
|
+
text: normalizedEvent.text ?? "",
|
|
70410
|
+
botUserId: this.botUserId,
|
|
70411
|
+
botUsername: this.botLabel,
|
|
70412
|
+
commandPrefixes: this.loadedConfig.raw.channels.slack.commandPrefixes
|
|
70413
|
+
}),
|
|
70414
|
+
wasMentioned: hasBotMention(normalizedEvent.text ?? "", this.botUserId),
|
|
70415
|
+
isBotOriginated: isBotOriginatedSlackEvent(normalizedEvent) && !this.loadedConfig.raw.channels.slack.allowBots
|
|
70384
70416
|
});
|
|
70385
70417
|
if (shouldGuide) {
|
|
70386
70418
|
try {
|