mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:40:44 +00:00
refactor: prune unused channel helpers
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
asOptionalRecord,
|
||||
hasNonEmptyString as sharedHasNonEmptyString,
|
||||
isRecord as sharedIsRecord,
|
||||
normalizeOptionalString,
|
||||
@@ -25,8 +24,6 @@ export const normalizeString = normalizeOptionalString;
|
||||
|
||||
export const isRecord = sharedIsRecord;
|
||||
|
||||
export const asRecord = asOptionalRecord;
|
||||
|
||||
export const hasNonEmptyString = sharedHasNonEmptyString;
|
||||
|
||||
export function formatFeishuApiError(
|
||||
@@ -359,10 +356,6 @@ export function parseCommentContentElements(params: {
|
||||
};
|
||||
}
|
||||
|
||||
export function extractCommentElementText(element: unknown): string | undefined {
|
||||
return parseCommentContentElements({ elements: [element] }).plainText;
|
||||
}
|
||||
|
||||
export function extractReplyText(
|
||||
reply: { content?: { elements?: unknown[] } } | undefined,
|
||||
): string | undefined {
|
||||
|
||||
@@ -83,20 +83,6 @@ export function isMentionForwardRequest(event: FeishuMessageEvent, botOpenId?: s
|
||||
return hasBotMention && hasOtherMention;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract message body from text (remove @ placeholders)
|
||||
*/
|
||||
export function extractMessageBody(text: string, allMentionKeys: string[]): string {
|
||||
let result = text;
|
||||
|
||||
// Remove all @ placeholders
|
||||
for (const key of allMentionKeys) {
|
||||
result = result.replace(new RegExp(escapeRegExp(key), "g"), "");
|
||||
}
|
||||
|
||||
return result.replace(/\s+/g, " ").trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Format @mention for text message
|
||||
*/
|
||||
@@ -104,13 +90,6 @@ export function formatMentionForText(target: MentionTarget): string {
|
||||
return `<at user_id="${target.openId}">${target.name}</at>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format @everyone for text message
|
||||
*/
|
||||
export function formatMentionAllForText(): string {
|
||||
return `<at user_id="all">Everyone</at>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format @mention for card message (lark_md)
|
||||
*/
|
||||
@@ -118,13 +97,6 @@ export function formatMentionForCard(target: MentionTarget): string {
|
||||
return `<at id=${target.openId}></at>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format @everyone for card message
|
||||
*/
|
||||
export function formatMentionAllForCard(): string {
|
||||
return `<at id=all></at>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build complete message with @mentions (text format)
|
||||
*/
|
||||
|
||||
@@ -72,11 +72,3 @@ export async function fetchBotIdentityForMonitor(
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
export async function fetchBotOpenIdForMonitor(
|
||||
account: ResolvedFeishuAccount,
|
||||
options: FetchBotOpenIdOptions = {},
|
||||
): Promise<string | undefined> {
|
||||
const identity = await fetchBotIdentityForMonitor(account, options);
|
||||
return identity.botOpenId;
|
||||
}
|
||||
|
||||
@@ -53,17 +53,6 @@ export function normalizeFeishuTarget(raw: string): string | null {
|
||||
return withoutProvider;
|
||||
}
|
||||
|
||||
export function formatFeishuTarget(id: string, type?: FeishuIdType): string {
|
||||
const trimmed = id.trim();
|
||||
if (type === "chat_id" || trimmed.startsWith(CHAT_ID_PREFIX)) {
|
||||
return `chat:${trimmed}`;
|
||||
}
|
||||
if (type === "open_id" || trimmed.startsWith(OPEN_ID_PREFIX)) {
|
||||
return `user:${trimmed}`;
|
||||
}
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
export function resolveReceiveIdType(id: string): "chat_id" | "open_id" | "user_id" {
|
||||
const trimmed = id.trim();
|
||||
const lowered = normalizeLowercaseStringOrEmpty(trimmed);
|
||||
|
||||
@@ -199,8 +199,6 @@ export async function verifyGoogleChatRequest(params: {
|
||||
return { ok: false, reason: "unsupported audience type" };
|
||||
}
|
||||
|
||||
export const GOOGLE_CHAT_SCOPE = CHAT_SCOPE;
|
||||
|
||||
export const __testing = {
|
||||
resetGoogleChatAuthForTests(): void {
|
||||
authCache.clear();
|
||||
|
||||
@@ -433,7 +433,3 @@ export function resolveGoogleChatWebhookPath(params: {
|
||||
}) ?? "/googlechat"
|
||||
);
|
||||
}
|
||||
|
||||
export function computeGoogleChatMediaMaxMb(params: { account: ResolvedGoogleChatAccount }) {
|
||||
return params.account.config.mediaMaxMb ?? 20;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
*/
|
||||
|
||||
import type { GatewayAccount } from "../types.js";
|
||||
import { normalizeMediaTags } from "../utils/media-tags.js";
|
||||
import { normalizePath } from "../utils/platform.js";
|
||||
import {
|
||||
sendPhoto,
|
||||
@@ -161,21 +160,6 @@ export function isInsideCodeBlock(text: string, position: number): boolean {
|
||||
|
||||
// ============ 媒体标签解析 ============
|
||||
|
||||
/**
|
||||
* 检测文本是否包含富媒体标签(忽略代码块内的标签)
|
||||
*/
|
||||
export function hasMediaTags(text: string): boolean {
|
||||
const normalized = normalizeMediaTags(text);
|
||||
const regex = createMediaTagRegex();
|
||||
let match: RegExpExecArray | null;
|
||||
while ((match = regex.exec(normalized)) !== null) {
|
||||
if (!isInsideCodeBlock(normalized, match.index)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** findFirstClosedMediaTag 的返回值 */
|
||||
export interface FirstClosedMediaTag {
|
||||
/** 标签前的纯文本 */
|
||||
|
||||
Reference in New Issue
Block a user