mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 01:28:27 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -25,17 +25,29 @@ type ResolveResult = {
|
||||
function resolvePreferredKind(
|
||||
kind?: ChannelsResolveOptions["kind"],
|
||||
): ChannelResolveKind | undefined {
|
||||
if (!kind || kind === "auto") return undefined;
|
||||
if (kind === "user") return "user";
|
||||
if (!kind || kind === "auto") {
|
||||
return undefined;
|
||||
}
|
||||
if (kind === "user") {
|
||||
return "user";
|
||||
}
|
||||
return "group";
|
||||
}
|
||||
|
||||
function detectAutoKind(input: string): ChannelResolveKind {
|
||||
const trimmed = input.trim();
|
||||
if (!trimmed) return "group";
|
||||
if (trimmed.startsWith("@")) return "user";
|
||||
if (/^<@!?/.test(trimmed)) return "user";
|
||||
if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(trimmed)) return "user";
|
||||
if (!trimmed) {
|
||||
return "group";
|
||||
}
|
||||
if (trimmed.startsWith("@")) {
|
||||
return "user";
|
||||
}
|
||||
if (/^<@!?/.test(trimmed)) {
|
||||
return "user";
|
||||
}
|
||||
if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(trimmed)) {
|
||||
return "user";
|
||||
}
|
||||
if (
|
||||
/^(user|discord|slack|matrix|msteams|teams|zalo|zalouser|googlechat|google-chat|gchat):/i.test(
|
||||
trimmed,
|
||||
@@ -47,7 +59,9 @@ function detectAutoKind(input: string): ChannelResolveKind {
|
||||
}
|
||||
|
||||
function formatResolveResult(result: ResolveResult): string {
|
||||
if (!result.resolved || !result.id) return `${result.input} -> unresolved`;
|
||||
if (!result.resolved || !result.id) {
|
||||
return `${result.input} -> unresolved`;
|
||||
}
|
||||
const name = result.name ? ` (${result.name})` : "";
|
||||
const note = result.note ? ` [${result.note}]` : "";
|
||||
return `${result.input} -> ${result.id}${name}${note}`;
|
||||
|
||||
Reference in New Issue
Block a user