mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-01 08:50:23 +00:00
refactor: dedupe tlon and voice-call lowercase helpers
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import type { MsgContext } from "../auto-reply/templating.js";
|
||||
import { normalizeOptionalString } from "../shared/string-coerce.js";
|
||||
import {
|
||||
normalizeLowercaseStringOrEmpty,
|
||||
normalizeOptionalString,
|
||||
} from "../shared/string-coerce.js";
|
||||
import { normalizeChatType } from "./chat-type.js";
|
||||
|
||||
function extractConversationId(from?: string): string | undefined {
|
||||
@@ -60,7 +63,7 @@ export function resolveConversationLabel(ctx: MsgContext): string | undefined {
|
||||
if (base.includes(id)) {
|
||||
return base;
|
||||
}
|
||||
if (base.toLowerCase().includes(" id:")) {
|
||||
if (normalizeLowercaseStringOrEmpty(base).includes(" id:")) {
|
||||
return base;
|
||||
}
|
||||
if (base.startsWith("#") || base.startsWith("@")) {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { normalizeLowercaseStringOrEmpty } from "../../shared/string-coerce.js";
|
||||
|
||||
export type ServicePrefix<TService extends string> = { prefix: string; service: TService };
|
||||
|
||||
export type ChatTargetPrefixesParams = {
|
||||
@@ -94,7 +96,7 @@ export function resolveServicePrefixedTarget<TService extends string, TTarget>(p
|
||||
if (!remainder) {
|
||||
throw new Error(`${prefix} target is required`);
|
||||
}
|
||||
const remainderLower = remainder.toLowerCase();
|
||||
const remainderLower = normalizeLowercaseStringOrEmpty(remainder);
|
||||
if (params.isChatTarget(remainderLower)) {
|
||||
return params.parseTarget(remainder);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user