@rokrokss/claude-slack-channel 0.3.0 → 0.3.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.
- package/lib/formatting.ts +20 -2
- package/package.json +1 -1
- package/server.ts +1 -1
package/lib/formatting.ts
CHANGED
|
@@ -2,6 +2,21 @@ export function fixSlackMrkdwn(text: string): string {
|
|
|
2
2
|
return text.replace(/\*([^*]+)\*/g, '\u200B*$1*\u200B')
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
+
function richTextElementToString(e: any): string {
|
|
6
|
+
switch (e.type) {
|
|
7
|
+
case 'link': return e.text || e.url || ''
|
|
8
|
+
case 'user': return `<@${e.user_id}>`
|
|
9
|
+
case 'channel': return `<#${e.channel_id}>`
|
|
10
|
+
case 'usergroup': return `<!subteam^${e.usergroup_id}>`
|
|
11
|
+
case 'emoji': return e.unicode ? String.fromCodePoint(...e.unicode.split('-').map((h: string) => parseInt(h, 16))) : `:${e.name}:`
|
|
12
|
+
case 'broadcast': return `<!${e.range}>`
|
|
13
|
+
case 'color': return e.value ?? ''
|
|
14
|
+
case 'date': return e.fallback ?? `<!date^${e.timestamp}^${e.format}>`
|
|
15
|
+
case 'team': return `<!team^${e.team_id}>`
|
|
16
|
+
default: return e.text ?? ''
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
5
20
|
export function extractMessageText(msg: Record<string, any>): string {
|
|
6
21
|
const parts: string[] = []
|
|
7
22
|
|
|
@@ -10,7 +25,7 @@ export function extractMessageText(msg: Record<string, any>): string {
|
|
|
10
25
|
if (block.type === 'rich_text' && block.elements) {
|
|
11
26
|
for (const elem of block.elements) {
|
|
12
27
|
if (elem.elements) {
|
|
13
|
-
parts.push(elem.elements.map(
|
|
28
|
+
parts.push(elem.elements.map(richTextElementToString).join(''))
|
|
14
29
|
}
|
|
15
30
|
}
|
|
16
31
|
} else if (block.type === 'section') {
|
|
@@ -21,7 +36,10 @@ export function extractMessageText(msg: Record<string, any>): string {
|
|
|
21
36
|
} else if (block.type === 'header') {
|
|
22
37
|
if (block.text?.text) parts.push(`*${block.text.text}*`)
|
|
23
38
|
} else if (block.type === 'context' && block.elements) {
|
|
24
|
-
const texts = block.elements.map((e: any) =>
|
|
39
|
+
const texts = block.elements.map((e: any) => {
|
|
40
|
+
if (e.type === 'image') return e.alt_text || '[image]'
|
|
41
|
+
return e.text ?? ''
|
|
42
|
+
}).filter(Boolean)
|
|
25
43
|
if (texts.length) parts.push(texts.join(' '))
|
|
26
44
|
} else if (block.type === 'divider') {
|
|
27
45
|
parts.push('---')
|
package/package.json
CHANGED
package/server.ts
CHANGED
|
@@ -160,7 +160,7 @@ async function resolveUserName(userId: string): Promise<string> {
|
|
|
160
160
|
// ---------------------------------------------------------------------------
|
|
161
161
|
|
|
162
162
|
const mcp = new McpServer(
|
|
163
|
-
{ name: 'slack-channel', version: '0.3.
|
|
163
|
+
{ name: 'slack-channel', version: '0.3.1' },
|
|
164
164
|
{
|
|
165
165
|
capabilities: {
|
|
166
166
|
experimental: {
|