@naturalcycles/nodejs-lib 15.82.0 → 15.82.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.
|
@@ -82,7 +82,7 @@ export class SlackService {
|
|
|
82
82
|
text = '```' + text + '```';
|
|
83
83
|
}
|
|
84
84
|
if (msg.mentions?.length) {
|
|
85
|
-
text += '\n' + msg.mentions.map(
|
|
85
|
+
text += '\n' + msg.mentions.map(formatSlackMention).join(' ');
|
|
86
86
|
}
|
|
87
87
|
const prefix = await messagePrefixHook(msg);
|
|
88
88
|
if (prefix === null)
|
|
@@ -139,3 +139,12 @@ export function slackDefaultMessagePrefixHook(msg) {
|
|
|
139
139
|
}
|
|
140
140
|
return tokens.filter(Boolean);
|
|
141
141
|
}
|
|
142
|
+
// Formats a Slack mention based on the ID type:
|
|
143
|
+
// - User IDs (U...) and Bot IDs (B...) use: <@ID>
|
|
144
|
+
// - User Group IDs (S...) use: <!subteam^ID>
|
|
145
|
+
function formatSlackMention(id) {
|
|
146
|
+
if (id.startsWith('S')) {
|
|
147
|
+
return `<!subteam^${id}>`;
|
|
148
|
+
}
|
|
149
|
+
return `<@${id}>`;
|
|
150
|
+
}
|
|
@@ -42,9 +42,10 @@ export interface SlackMessage<CTX = any> extends SlackMessageProps {
|
|
|
42
42
|
*/
|
|
43
43
|
kv?: AnyObject;
|
|
44
44
|
/**
|
|
45
|
-
* Slack
|
|
46
|
-
*
|
|
47
|
-
*
|
|
45
|
+
* Slack IDs to mention at the end of the message.
|
|
46
|
+
* Supports:
|
|
47
|
+
* - User IDs (e.g., 'U1234567890') - click profile → "..." → "Copy member ID"
|
|
48
|
+
* - User Group IDs (e.g., 'S1234567890') - from user group settings
|
|
48
49
|
*/
|
|
49
50
|
mentions?: string[];
|
|
50
51
|
/**
|
package/package.json
CHANGED
|
@@ -51,9 +51,10 @@ export interface SlackMessage<CTX = any> extends SlackMessageProps {
|
|
|
51
51
|
kv?: AnyObject
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* Slack
|
|
55
|
-
*
|
|
56
|
-
*
|
|
54
|
+
* Slack IDs to mention at the end of the message.
|
|
55
|
+
* Supports:
|
|
56
|
+
* - User IDs (e.g., 'U1234567890') - click profile → "..." → "Copy member ID"
|
|
57
|
+
* - User Group IDs (e.g., 'S1234567890') - from user group settings
|
|
57
58
|
*/
|
|
58
59
|
mentions?: string[]
|
|
59
60
|
|
|
@@ -109,7 +109,7 @@ export class SlackService<CTX = any> {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
if (msg.mentions?.length) {
|
|
112
|
-
text += '\n' + msg.mentions.map(
|
|
112
|
+
text += '\n' + msg.mentions.map(formatSlackMention).join(' ')
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
const prefix = await messagePrefixHook(msg)
|
|
@@ -191,3 +191,13 @@ export function slackDefaultMessagePrefixHook(msg: SlackMessage): string[] {
|
|
|
191
191
|
|
|
192
192
|
return tokens.filter(Boolean)
|
|
193
193
|
}
|
|
194
|
+
|
|
195
|
+
// Formats a Slack mention based on the ID type:
|
|
196
|
+
// - User IDs (U...) and Bot IDs (B...) use: <@ID>
|
|
197
|
+
// - User Group IDs (S...) use: <!subteam^ID>
|
|
198
|
+
function formatSlackMention(id: string): string {
|
|
199
|
+
if (id.startsWith('S')) {
|
|
200
|
+
return `<!subteam^${id}>`
|
|
201
|
+
}
|
|
202
|
+
return `<@${id}>`
|
|
203
|
+
}
|