Skip to content

Commit 2b96f53

Browse files
committed
fix(feishu): split message and mention types
1 parent 5cf15f8 commit 2b96f53

7 files changed

Lines changed: 57 additions & 57 deletions

File tree

extensions/feishu/src/bot.ts

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ import { resolveFeishuReasoningPreviewEnabled } from "./reasoning-preview.js";
5454
import { createFeishuReplyDispatcher } from "./reply-dispatcher.js";
5555
import { getFeishuRuntime } from "./runtime.js";
5656
import { getMessageFeishu, listFeishuThreadMessages, sendMessageFeishu } from "./send.js";
57+
export type { FeishuBotAddedEvent, FeishuMessageEvent } from "./event-types.js";
58+
import type { FeishuMessageEvent } from "./event-types.js";
5759
import type { FeishuMessageContext, FeishuMessageInfo } from "./types.js";
5860
import type { DynamicAgentCreationConfig } from "./types.js";
5961

@@ -63,49 +65,6 @@ export { toMessageResourceType } from "./bot-content.js";
6365
// Key: appId or "default", Value: timestamp of last notification
6466
const permissionErrorNotifiedAt = new Map<string, number>();
6567
const PERMISSION_ERROR_COOLDOWN_MS = 5 * 60 * 1000; // 5 minutes
66-
export type FeishuMessageEvent = {
67-
sender: {
68-
sender_id: {
69-
open_id?: string;
70-
user_id?: string;
71-
union_id?: string;
72-
};
73-
sender_type?: string;
74-
tenant_key?: string;
75-
};
76-
message: {
77-
message_id: string;
78-
root_id?: string;
79-
parent_id?: string;
80-
thread_id?: string;
81-
chat_id: string;
82-
chat_type: "p2p" | "group" | "private";
83-
message_type: string;
84-
content: string;
85-
create_time?: string;
86-
mentions?: Array<{
87-
key: string;
88-
id: {
89-
open_id?: string;
90-
user_id?: string;
91-
union_id?: string;
92-
};
93-
name: string;
94-
tenant_key?: string;
95-
}>;
96-
};
97-
};
98-
99-
export type FeishuBotAddedEvent = {
100-
chat_id: string;
101-
operator_id: {
102-
open_id?: string;
103-
user_id?: string;
104-
union_id?: string;
105-
};
106-
external: boolean;
107-
operator_tenant_key?: string;
108-
};
10968

11069
// --- Broadcast support ---
11170
// Resolve broadcast agent list for a given peer (group) ID.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
export type FeishuMessageEvent = {
2+
sender: {
3+
sender_id: {
4+
open_id?: string;
5+
user_id?: string;
6+
union_id?: string;
7+
};
8+
sender_type?: string;
9+
tenant_key?: string;
10+
};
11+
message: {
12+
message_id: string;
13+
root_id?: string;
14+
parent_id?: string;
15+
thread_id?: string;
16+
chat_id: string;
17+
chat_type: "p2p" | "group" | "private";
18+
message_type: string;
19+
content: string;
20+
create_time?: string;
21+
mentions?: Array<{
22+
key: string;
23+
id: {
24+
open_id?: string;
25+
user_id?: string;
26+
union_id?: string;
27+
};
28+
name: string;
29+
tenant_key?: string;
30+
}>;
31+
};
32+
};
33+
34+
export type FeishuBotAddedEvent = {
35+
chat_id: string;
36+
operator_id: {
37+
open_id?: string;
38+
user_id?: string;
39+
union_id?: string;
40+
};
41+
external: boolean;
42+
operator_tenant_key?: string;
43+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export type MentionTarget = {
2+
openId: string;
3+
name: string;
4+
key: string; // Placeholder in original message, e.g. @_user_1
5+
};

extensions/feishu/src/mention.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import type { FeishuMessageEvent } from "./bot.js";
1+
import type { FeishuMessageEvent } from "./event-types.js";
2+
export type { MentionTarget } from "./mention-target.types.js";
3+
import type { MentionTarget } from "./mention-target.types.js";
24

35
/**
46
* Escape regex metacharacters so user-controlled mention fields are treated literally.
@@ -7,15 +9,6 @@ export function escapeRegExp(input: string): string {
79
return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
810
}
911

10-
/**
11-
* Mention target user info
12-
*/
13-
export type MentionTarget = {
14-
openId: string;
15-
name: string;
16-
key: string; // Placeholder in original message, e.g. @_user_1
17-
};
18-
1912
/**
2013
* Extract mention targets from message event (excluding the bot itself)
2114
*/

extensions/feishu/src/reply-dispatcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import { resolveFeishuRuntimeAccount } from "./accounts.js";
99
import { createFeishuClient } from "./client.js";
1010
import { sendMediaFeishu } from "./media.js";
11-
import type { MentionTarget } from "./mention.js";
11+
import type { MentionTarget } from "./mention-target.types.js";
1212
import { buildMentionedCardContent } from "./mention.js";
1313
import {
1414
createReplyPrefixContext,

extensions/feishu/src/send.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
import type { ClawdbotConfig } from "../runtime-api.js";
88
import { resolveFeishuRuntimeAccount } from "./accounts.js";
99
import { createFeishuClient } from "./client.js";
10-
import type { MentionTarget } from "./mention.js";
10+
import type { MentionTarget } from "./mention-target.types.js";
1111
import { buildMentionedCardContent, buildMentionedMessage } from "./mention.js";
1212
import { parsePostContent } from "./post.js";
1313
import { assertFeishuMessageApiSuccess, toFeishuSendResult } from "./send-result.js";

extensions/feishu/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { BaseProbeResult } from "../runtime-api.js";
1+
import type { BaseProbeResult } from "openclaw/plugin-sdk/core";
22
import type {
33
FeishuConfigSchema,
44
FeishuGroupSchema,
55
FeishuAccountConfigSchema,
66
z,
77
} from "./config-schema.js";
8-
import type { MentionTarget } from "./mention.js";
8+
import type { MentionTarget } from "./mention-target.types.js";
99

1010
export type FeishuConfig = z.infer<typeof FeishuConfigSchema>;
1111
export type FeishuGroupConfig = z.infer<typeof FeishuGroupSchema>;

0 commit comments

Comments
 (0)