mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 09:41:41 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -15,14 +15,28 @@ export type AckReactionGateParams = {
|
||||
|
||||
export function shouldAckReaction(params: AckReactionGateParams): boolean {
|
||||
const scope = params.scope ?? "group-mentions";
|
||||
if (scope === "off" || scope === "none") return false;
|
||||
if (scope === "all") return true;
|
||||
if (scope === "direct") return params.isDirect;
|
||||
if (scope === "group-all") return params.isGroup;
|
||||
if (scope === "off" || scope === "none") {
|
||||
return false;
|
||||
}
|
||||
if (scope === "all") {
|
||||
return true;
|
||||
}
|
||||
if (scope === "direct") {
|
||||
return params.isDirect;
|
||||
}
|
||||
if (scope === "group-all") {
|
||||
return params.isGroup;
|
||||
}
|
||||
if (scope === "group-mentions") {
|
||||
if (!params.isMentionableGroup) return false;
|
||||
if (!params.requireMention) return false;
|
||||
if (!params.canDetectMention) return false;
|
||||
if (!params.isMentionableGroup) {
|
||||
return false;
|
||||
}
|
||||
if (!params.requireMention) {
|
||||
return false;
|
||||
}
|
||||
if (!params.canDetectMention) {
|
||||
return false;
|
||||
}
|
||||
return params.effectiveWasMentioned || params.shouldBypassMention === true;
|
||||
}
|
||||
return false;
|
||||
@@ -37,11 +51,21 @@ export function shouldAckReactionForWhatsApp(params: {
|
||||
wasMentioned: boolean;
|
||||
groupActivated: boolean;
|
||||
}): boolean {
|
||||
if (!params.emoji) return false;
|
||||
if (params.isDirect) return params.directEnabled;
|
||||
if (!params.isGroup) return false;
|
||||
if (params.groupMode === "never") return false;
|
||||
if (params.groupMode === "always") return true;
|
||||
if (!params.emoji) {
|
||||
return false;
|
||||
}
|
||||
if (params.isDirect) {
|
||||
return params.directEnabled;
|
||||
}
|
||||
if (!params.isGroup) {
|
||||
return false;
|
||||
}
|
||||
if (params.groupMode === "never") {
|
||||
return false;
|
||||
}
|
||||
if (params.groupMode === "always") {
|
||||
return true;
|
||||
}
|
||||
return shouldAckReaction({
|
||||
scope: "group-mentions",
|
||||
isDirect: false,
|
||||
@@ -61,11 +85,19 @@ export function removeAckReactionAfterReply(params: {
|
||||
remove: () => Promise<void>;
|
||||
onError?: (err: unknown) => void;
|
||||
}) {
|
||||
if (!params.removeAfterReply) return;
|
||||
if (!params.ackReactionPromise) return;
|
||||
if (!params.ackReactionValue) return;
|
||||
if (!params.removeAfterReply) {
|
||||
return;
|
||||
}
|
||||
if (!params.ackReactionPromise) {
|
||||
return;
|
||||
}
|
||||
if (!params.ackReactionValue) {
|
||||
return;
|
||||
}
|
||||
void params.ackReactionPromise.then((didAck) => {
|
||||
if (!didAck) return;
|
||||
if (!didAck) {
|
||||
return;
|
||||
}
|
||||
params.remove().catch((err) => params.onError?.(err));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user