mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 04:31:10 +00:00
fix(plugins): clean xai and qqbot lint
This commit is contained in:
@@ -437,7 +437,7 @@ export async function sendChannelMessage(
|
||||
channelId: string,
|
||||
content: string,
|
||||
msgId?: string,
|
||||
): Promise<{ id: string; timestamp: string }> {
|
||||
): Promise<MessageResponse> {
|
||||
return apiRequest(accessToken, "POST", `/channels/${channelId}/messages`, {
|
||||
content,
|
||||
...(msgId ? { msg_id: msgId } : {}),
|
||||
@@ -499,9 +499,11 @@ export async function sendProactiveGroupMessage(
|
||||
accessToken: string,
|
||||
groupOpenid: string,
|
||||
content: string,
|
||||
): Promise<{ id: string; timestamp: string }> {
|
||||
): Promise<MessageResponse> {
|
||||
const body = buildProactiveMessageBody(appId, content);
|
||||
return apiRequest(accessToken, "POST", `/v2/groups/${groupOpenid}/messages`, body);
|
||||
return sendAndNotify(appId, accessToken, "POST", `/v2/groups/${groupOpenid}/messages`, body, {
|
||||
text: content,
|
||||
});
|
||||
}
|
||||
|
||||
// Rich media message support.
|
||||
|
||||
@@ -50,8 +50,18 @@ interface MessageReplyRecord {
|
||||
firstReplyAt: number;
|
||||
}
|
||||
|
||||
type QQMessageResult = {
|
||||
ext_info?: {
|
||||
ref_idx?: string;
|
||||
};
|
||||
};
|
||||
|
||||
const messageReplyTracker = new Map<string, MessageReplyRecord>();
|
||||
|
||||
function getRefIdx(result: QQMessageResult): string | undefined {
|
||||
return result.ext_info?.ref_idx;
|
||||
}
|
||||
|
||||
/** Result of the passive-reply limit check. */
|
||||
export interface ReplyLimitResult {
|
||||
allowed: boolean;
|
||||
@@ -1012,7 +1022,7 @@ export async function sendText(ctx: OutboundContext): Promise<OutboundResult> {
|
||||
channel: "qqbot",
|
||||
messageId: result.id,
|
||||
timestamp: result.timestamp,
|
||||
refIdx: (result as { ext_info?: { ref_idx?: string } }).ext_info?.ref_idx,
|
||||
refIdx: getRefIdx(result),
|
||||
};
|
||||
}
|
||||
} else {
|
||||
@@ -1029,7 +1039,7 @@ export async function sendText(ctx: OutboundContext): Promise<OutboundResult> {
|
||||
channel: "qqbot",
|
||||
messageId: result.id,
|
||||
timestamp: result.timestamp,
|
||||
refIdx: (result as any).ext_info?.ref_idx,
|
||||
refIdx: getRefIdx(result),
|
||||
};
|
||||
} else if (target.type === "group") {
|
||||
const result = await sendProactiveGroupMessage(
|
||||
@@ -1042,7 +1052,7 @@ export async function sendText(ctx: OutboundContext): Promise<OutboundResult> {
|
||||
channel: "qqbot",
|
||||
messageId: result.id,
|
||||
timestamp: result.timestamp,
|
||||
refIdx: (result as any).ext_info?.ref_idx,
|
||||
refIdx: getRefIdx(result),
|
||||
};
|
||||
} else {
|
||||
const result = await sendChannelMessage(accessToken, target.id, item.content);
|
||||
@@ -1050,7 +1060,7 @@ export async function sendText(ctx: OutboundContext): Promise<OutboundResult> {
|
||||
channel: "qqbot",
|
||||
messageId: result.id,
|
||||
timestamp: result.timestamp,
|
||||
refIdx: (result as any).ext_info?.ref_idx,
|
||||
refIdx: getRefIdx(result),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1123,7 +1133,7 @@ export async function sendText(ctx: OutboundContext): Promise<OutboundResult> {
|
||||
channel: "qqbot",
|
||||
messageId: result.id,
|
||||
timestamp: result.timestamp,
|
||||
refIdx: (result as any).ext_info?.ref_idx,
|
||||
refIdx: getRefIdx(result),
|
||||
};
|
||||
} else if (target.type === "group") {
|
||||
const result = await sendProactiveGroupMessage(account.appId, accessToken, target.id, text);
|
||||
@@ -1131,7 +1141,7 @@ export async function sendText(ctx: OutboundContext): Promise<OutboundResult> {
|
||||
channel: "qqbot",
|
||||
messageId: result.id,
|
||||
timestamp: result.timestamp,
|
||||
refIdx: (result as any).ext_info?.ref_idx,
|
||||
refIdx: getRefIdx(result),
|
||||
};
|
||||
} else {
|
||||
const result = await sendChannelMessage(accessToken, target.id, text);
|
||||
@@ -1139,7 +1149,7 @@ export async function sendText(ctx: OutboundContext): Promise<OutboundResult> {
|
||||
channel: "qqbot",
|
||||
messageId: result.id,
|
||||
timestamp: result.timestamp,
|
||||
refIdx: (result as any).ext_info?.ref_idx,
|
||||
refIdx: getRefIdx(result),
|
||||
};
|
||||
}
|
||||
return outResult;
|
||||
@@ -1170,7 +1180,7 @@ export async function sendText(ctx: OutboundContext): Promise<OutboundResult> {
|
||||
channel: "qqbot",
|
||||
messageId: result.id,
|
||||
timestamp: result.timestamp,
|
||||
refIdx: (result as any).ext_info?.ref_idx,
|
||||
refIdx: getRefIdx(result),
|
||||
};
|
||||
}
|
||||
} catch (err) {
|
||||
@@ -1222,7 +1232,7 @@ export async function sendProactiveMessage(
|
||||
channel: "qqbot",
|
||||
messageId: result.id,
|
||||
timestamp: result.timestamp,
|
||||
refIdx: (result as any).ext_info?.ref_idx,
|
||||
refIdx: getRefIdx(result),
|
||||
};
|
||||
} else if (target.type === "group") {
|
||||
debugLog(
|
||||
@@ -1236,7 +1246,7 @@ export async function sendProactiveMessage(
|
||||
channel: "qqbot",
|
||||
messageId: result.id,
|
||||
timestamp: result.timestamp,
|
||||
refIdx: (result as any).ext_info?.ref_idx,
|
||||
refIdx: getRefIdx(result),
|
||||
};
|
||||
} else {
|
||||
debugLog(
|
||||
@@ -1250,7 +1260,7 @@ export async function sendProactiveMessage(
|
||||
channel: "qqbot",
|
||||
messageId: result.id,
|
||||
timestamp: result.timestamp,
|
||||
refIdx: (result as any).ext_info?.ref_idx,
|
||||
refIdx: getRefIdx(result),
|
||||
};
|
||||
}
|
||||
return outResult;
|
||||
|
||||
@@ -223,7 +223,7 @@ export function sanitizeFileName(name: string): string {
|
||||
result = result.normalize("NFC");
|
||||
|
||||
// Drop ASCII control characters while keeping printable Unicode content.
|
||||
result = result.replace(/[\x00-\x1F\x7F]/g, "");
|
||||
result = result.replace(/\p{Cc}/gu, "");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ export default defineSingleProviderPluginEntry({
|
||||
// private config layout. Callers may receive a real key from the active
|
||||
// runtime snapshot or a non-secret SecretRef marker from source config.
|
||||
resolveSyntheticAuth: ({ config }) => {
|
||||
const fallbackAuth = resolveFallbackXaiAuth(config as OpenClawConfig | undefined);
|
||||
const fallbackAuth = resolveFallbackXaiAuth(config);
|
||||
if (!fallbackAuth) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -243,14 +243,11 @@ export function createXaiWebSearchProvider(): WebSearchProviderPlugin {
|
||||
model: resolveXaiWebSearchModel(searchConfig),
|
||||
apiKey,
|
||||
timeoutSeconds: resolveTimeoutSeconds(
|
||||
(searchConfig?.timeoutSeconds as number | undefined) ?? undefined,
|
||||
searchConfig?.timeoutSeconds,
|
||||
DEFAULT_TIMEOUT_SECONDS,
|
||||
),
|
||||
inlineCitations: resolveXaiInlineCitations(searchConfig),
|
||||
cacheTtlMs: resolveCacheTtlMs(
|
||||
(searchConfig?.cacheTtlMinutes as number | undefined) ?? undefined,
|
||||
DEFAULT_CACHE_TTL_MINUTES,
|
||||
),
|
||||
cacheTtlMs: resolveCacheTtlMs(searchConfig?.cacheTtlMinutes, DEFAULT_CACHE_TTL_MINUTES),
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user