mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 14:58:26 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -20,9 +20,13 @@ export type AnnounceTarget = {
|
||||
export function resolveAnnounceTargetFromKey(sessionKey: string): AnnounceTarget | null {
|
||||
const rawParts = sessionKey.split(":").filter(Boolean);
|
||||
const parts = rawParts.length >= 3 && rawParts[0] === "agent" ? rawParts.slice(2) : rawParts;
|
||||
if (parts.length < 3) return null;
|
||||
if (parts.length < 3) {
|
||||
return null;
|
||||
}
|
||||
const [channelRaw, kind, ...rest] = parts;
|
||||
if (kind !== "group" && kind !== "channel") return null;
|
||||
if (kind !== "group" && kind !== "channel") {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Extract topic/thread ID from rest (supports both :topic: and :thread:)
|
||||
// Telegram uses :topic:, other platforms use :thread:
|
||||
@@ -39,12 +43,18 @@ export function resolveAnnounceTargetFromKey(sessionKey: string): AnnounceTarget
|
||||
// Remove :topic:N or :thread:N suffix from ID for target
|
||||
const id = match ? restJoined.replace(/:(topic|thread):\d+$/, "") : restJoined.trim();
|
||||
|
||||
if (!id) return null;
|
||||
if (!channelRaw) return null;
|
||||
if (!id) {
|
||||
return null;
|
||||
}
|
||||
if (!channelRaw) {
|
||||
return null;
|
||||
}
|
||||
const normalizedChannel = normalizeAnyChannelId(channelRaw) ?? normalizeChatChannelId(channelRaw);
|
||||
const channel = normalizedChannel ?? channelRaw.toLowerCase();
|
||||
const kindTarget = (() => {
|
||||
if (!normalizedChannel) return id;
|
||||
if (!normalizedChannel) {
|
||||
return id;
|
||||
}
|
||||
if (normalizedChannel === "discord" || normalizedChannel === "slack") {
|
||||
return `channel:${id}`;
|
||||
}
|
||||
@@ -148,7 +158,9 @@ export function isReplySkip(text?: string) {
|
||||
export function resolvePingPongTurns(cfg?: OpenClawConfig) {
|
||||
const raw = cfg?.session?.agentToAgent?.maxPingPongTurns;
|
||||
const fallback = DEFAULT_PING_PONG_TURNS;
|
||||
if (typeof raw !== "number" || !Number.isFinite(raw)) return fallback;
|
||||
if (typeof raw !== "number" || !Number.isFinite(raw)) {
|
||||
return fallback;
|
||||
}
|
||||
const rounded = Math.floor(raw);
|
||||
return Math.max(0, Math.min(MAX_PING_PONG_TURNS, rounded));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user