@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(s => `<@${s}>`).join(' ');
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 Member IDs to mention at the end of the message.
46
- * Use Member IDs (e.g., 'U1234567890'), not usernames.
47
- * To find a Member ID: click on their profile in Slack → "..." → "Copy member ID".
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
3
  "type": "module",
4
- "version": "15.82.0",
4
+ "version": "15.82.1",
5
5
  "dependencies": {
6
6
  "@naturalcycles/js-lib": "^15",
7
7
  "@types/js-yaml": "^4",
@@ -51,9 +51,10 @@ export interface SlackMessage<CTX = any> extends SlackMessageProps {
51
51
  kv?: AnyObject
52
52
 
53
53
  /**
54
- * Slack Member IDs to mention at the end of the message.
55
- * Use Member IDs (e.g., 'U1234567890'), not usernames.
56
- * To find a Member ID: click on their profile in Slack → "..." → "Copy member ID".
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(s => `<@${s}>`).join(' ')
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
+ }