mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:50:43 +00:00
refactor: trim qqbot helper exports
This commit is contained in:
@@ -291,6 +291,3 @@ export interface Credentials {
|
||||
appId: string;
|
||||
clientSecret: string;
|
||||
}
|
||||
|
||||
// Re-export getNextMsgSeq for consumers that import from messages.ts.
|
||||
export { getNextMsgSeq } from "./routes.js";
|
||||
|
||||
@@ -211,7 +211,7 @@ export function buildPartFinishPersistentPolicy(
|
||||
}
|
||||
|
||||
/** Business error codes that trigger persistent part-finish retry. */
|
||||
export const PART_FINISH_RETRYABLE_CODES: Set<number> = new Set([40093001]);
|
||||
const PART_FINISH_RETRYABLE_CODES: Set<number> = new Set([40093001]);
|
||||
|
||||
/** upload_prepare error code indicating daily limit exceeded. */
|
||||
export const UPLOAD_PREPARE_FALLBACK_CODE = 40093002;
|
||||
|
||||
@@ -73,7 +73,7 @@ export interface DeliverDeps {
|
||||
// ---- Exported types ----
|
||||
|
||||
/** Maximum text length for a single QQ Bot message. */
|
||||
export const TEXT_CHUNK_LIMIT = 5000;
|
||||
const TEXT_CHUNK_LIMIT = 5000;
|
||||
|
||||
export interface DeliverEventContext {
|
||||
type: "c2c" | "guild" | "dm" | "group";
|
||||
|
||||
@@ -803,6 +803,6 @@ export function accountToCreds(account: { appId: string; clientSecret: string })
|
||||
}
|
||||
|
||||
/** Check whether a target type supports rich media (C2C and Group only). */
|
||||
export function supportsRichMedia(targetType: string): boolean {
|
||||
function supportsRichMedia(targetType: string): boolean {
|
||||
return targetType === "c2c" || targetType === "group";
|
||||
}
|
||||
|
||||
@@ -31,11 +31,11 @@ export interface SendQueueItem {
|
||||
}
|
||||
|
||||
/** 统一的媒体标签正则 — 匹配标准化后的 6 种标签 */
|
||||
export const MEDIA_TAG_REGEX =
|
||||
const MEDIA_TAG_REGEX =
|
||||
/<(qqimg|qqvoice|qqvideo|qqfile|qqmedia|img)>([^<>]+)<\/(?:qqimg|qqvoice|qqvideo|qqfile|qqmedia|img)>/gi;
|
||||
|
||||
/** 创建一个新的全局标签正则实例(每次调用 reset lastIndex) */
|
||||
export function createMediaTagRegex(): RegExp {
|
||||
function createMediaTagRegex(): RegExp {
|
||||
return new RegExp(MEDIA_TAG_REGEX.source, MEDIA_TAG_REGEX.flags);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export interface MediaSendContext {
|
||||
* 此方法在 gateway.ts deliver 回调、outbound.ts sendText、
|
||||
* streaming.ts sendMediaQueue 中共用。
|
||||
*/
|
||||
export function fixPathEncoding(
|
||||
function fixPathEncoding(
|
||||
mediaPath: string,
|
||||
log?: { debug?: (msg: string) => void; error?: (msg: string) => void },
|
||||
): string {
|
||||
@@ -133,7 +133,7 @@ export function fixPathEncoding(
|
||||
* @param position 要检测的位置(字符索引)
|
||||
* @returns 如果 position 在围栏代码块内返回 true
|
||||
*/
|
||||
export function isInsideCodeBlock(text: string, position: number): boolean {
|
||||
function isInsideCodeBlock(text: string, position: number): boolean {
|
||||
const fenceRegex = /^(`{3,})[^\n]*$/gm;
|
||||
let fenceMatch: RegExpExecArray | null;
|
||||
let openFence: { pos: number; ticks: number } | null = null;
|
||||
|
||||
@@ -63,7 +63,7 @@ export const ChannelApiSchema = {
|
||||
* Build the full API URL from base + path + query params.
|
||||
* 拼接 API 基地址 + 路径 + 查询参数。
|
||||
*/
|
||||
export function buildUrl(path: string, query?: Record<string, string>): string {
|
||||
function buildUrl(path: string, query?: Record<string, string>): string {
|
||||
let url = `${API_BASE}${path}`;
|
||||
if (query && Object.keys(query).length > 0) {
|
||||
const params = new URLSearchParams();
|
||||
@@ -84,7 +84,7 @@ export function buildUrl(path: string, query?: Record<string, string>): string {
|
||||
* Validate API path format; returns an error string or null if valid.
|
||||
* 校验 API 路径格式,返回错误描述或 null(合法)。
|
||||
*/
|
||||
export function validatePath(path: string): string | null {
|
||||
function validatePath(path: string): string | null {
|
||||
if (!path.startsWith("/")) {
|
||||
return "path must start with /";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user