refactor: prune unused channel helpers · openclaw/openclaw@111432a
steipete
·
2026-05-01
·
via Recent Commits to openclaw:main
File tree
qqbot/src/engine/messaging
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { |
2 | | -asOptionalRecord, |
3 | 2 | hasNonEmptyString as sharedHasNonEmptyString, |
4 | 3 | isRecord as sharedIsRecord, |
5 | 4 | normalizeOptionalString, |
@@ -25,8 +24,6 @@ export const normalizeString = normalizeOptionalString;
|
25 | 24 | |
26 | 25 | export const isRecord = sharedIsRecord; |
27 | 26 | |
28 | | -export const asRecord = asOptionalRecord; |
29 | | - |
30 | 27 | export const hasNonEmptyString = sharedHasNonEmptyString; |
31 | 28 | |
32 | 29 | export function formatFeishuApiError( |
@@ -359,10 +356,6 @@ export function parseCommentContentElements(params: {
|
359 | 356 | }; |
360 | 357 | } |
361 | 358 | |
362 | | -export function extractCommentElementText(element: unknown): string | undefined { |
363 | | -return parseCommentContentElements({ elements: [element] }).plainText; |
364 | | -} |
365 | | - |
366 | 359 | export function extractReplyText( |
367 | 360 | reply: { content?: { elements?: unknown[] } } | undefined, |
368 | 361 | ): string | undefined { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -83,48 +83,20 @@ export function isMentionForwardRequest(event: FeishuMessageEvent, botOpenId?: s
|
83 | 83 | return hasBotMention && hasOtherMention; |
84 | 84 | } |
85 | 85 | |
86 | | -/** |
87 | | - * Extract message body from text (remove @ placeholders) |
88 | | - */ |
89 | | -export function extractMessageBody(text: string, allMentionKeys: string[]): string { |
90 | | -let result = text; |
91 | | - |
92 | | -// Remove all @ placeholders |
93 | | -for (const key of allMentionKeys) { |
94 | | -result = result.replace(new RegExp(escapeRegExp(key), "g"), ""); |
95 | | -} |
96 | | - |
97 | | -return result.replace(/\s+/g, " ").trim(); |
98 | | -} |
99 | | - |
100 | 86 | /** |
101 | 87 | * Format @mention for text message |
102 | 88 | */ |
103 | 89 | export function formatMentionForText(target: MentionTarget): string { |
104 | 90 | return `<at user_id="${target.openId}">${target.name}</at>`; |
105 | 91 | } |
106 | 92 | |
107 | | -/** |
108 | | - * Format @everyone for text message |
109 | | - */ |
110 | | -export function formatMentionAllForText(): string { |
111 | | -return `<at user_id="all">Everyone</at>`; |
112 | | -} |
113 | | - |
114 | 93 | /** |
115 | 94 | * Format @mention for card message (lark_md) |
116 | 95 | */ |
117 | 96 | export function formatMentionForCard(target: MentionTarget): string { |
118 | 97 | return `<at id=${target.openId}></at>`; |
119 | 98 | } |
120 | 99 | |
121 | | -/** |
122 | | - * Format @everyone for card message |
123 | | - */ |
124 | | -export function formatMentionAllForCard(): string { |
125 | | -return `<at id=all></at>`; |
126 | | -} |
127 | | - |
128 | 100 | /** |
129 | 101 | * Build complete message with @mentions (text format) |
130 | 102 | */ |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -72,11 +72,3 @@ export async function fetchBotIdentityForMonitor(
|
72 | 72 | } |
73 | 73 | return {}; |
74 | 74 | } |
75 | | - |
76 | | -export async function fetchBotOpenIdForMonitor( |
77 | | -account: ResolvedFeishuAccount, |
78 | | -options: FetchBotOpenIdOptions = {}, |
79 | | -): Promise<string | undefined> { |
80 | | -const identity = await fetchBotIdentityForMonitor(account, options); |
81 | | -return identity.botOpenId; |
82 | | -} |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -53,17 +53,6 @@ export function normalizeFeishuTarget(raw: string): string | null {
|
53 | 53 | return withoutProvider; |
54 | 54 | } |
55 | 55 | |
56 | | -export function formatFeishuTarget(id: string, type?: FeishuIdType): string { |
57 | | -const trimmed = id.trim(); |
58 | | -if (type === "chat_id" || trimmed.startsWith(CHAT_ID_PREFIX)) { |
59 | | -return `chat:${trimmed}`; |
60 | | -} |
61 | | -if (type === "open_id" || trimmed.startsWith(OPEN_ID_PREFIX)) { |
62 | | -return `user:${trimmed}`; |
63 | | -} |
64 | | -return trimmed; |
65 | | -} |
66 | | - |
67 | 56 | export function resolveReceiveIdType(id: string): "chat_id" | "open_id" | "user_id" { |
68 | 57 | const trimmed = id.trim(); |
69 | 58 | const lowered = normalizeLowercaseStringOrEmpty(trimmed); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -199,8 +199,6 @@ export async function verifyGoogleChatRequest(params: {
|
199 | 199 | return { ok: false, reason: "unsupported audience type" }; |
200 | 200 | } |
201 | 201 | |
202 | | -export const GOOGLE_CHAT_SCOPE = CHAT_SCOPE; |
203 | | - |
204 | 202 | export const __testing = { |
205 | 203 | resetGoogleChatAuthForTests(): void { |
206 | 204 | authCache.clear(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -433,7 +433,3 @@ export function resolveGoogleChatWebhookPath(params: {
|
433 | 433 | }) ?? "/googlechat" |
434 | 434 | ); |
435 | 435 | } |
436 | | - |
437 | | -export function computeGoogleChatMediaMaxMb(params: { account: ResolvedGoogleChatAccount }) { |
438 | | -return params.account.config.mediaMaxMb ?? 20; |
439 | | -} |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,7 +6,6 @@
|
6 | 6 | */ |
7 | 7 | |
8 | 8 | import type { GatewayAccount } from "../types.js"; |
9 | | -import { normalizeMediaTags } from "../utils/media-tags.js"; |
10 | 9 | import { normalizePath } from "../utils/platform.js"; |
11 | 10 | import { |
12 | 11 | sendPhoto, |
@@ -161,21 +160,6 @@ export function isInsideCodeBlock(text: string, position: number): boolean {
|
161 | 160 | |
162 | 161 | // ============ 媒体标签解析 ============ |
163 | 162 | |
164 | | -/** |
165 | | - * 检测文本是否包含富媒体标签(忽略代码块内的标签) |
166 | | - */ |
167 | | -export function hasMediaTags(text: string): boolean { |
168 | | -const normalized = normalizeMediaTags(text); |
169 | | -const regex = createMediaTagRegex(); |
170 | | -let match: RegExpExecArray | null; |
171 | | -while ((match = regex.exec(normalized)) !== null) { |
172 | | -if (!isInsideCodeBlock(normalized, match.index)) { |
173 | | -return true; |
174 | | -} |
175 | | -} |
176 | | -return false; |
177 | | -} |
178 | | - |
179 | 163 | /** findFirstClosedMediaTag 的返回值 */ |
180 | 164 | export interface FirstClosedMediaTag { |
181 | 165 | /** 标签前的纯文本 */ |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。