chore: Enable "curly" rule to avoid single-statement if confusion/errors.

This commit is contained in:
cpojer
2026-01-31 16:19:20 +09:00
parent 009b16fab8
commit 5ceff756e1
1266 changed files with 27871 additions and 9393 deletions

View File

@@ -8,10 +8,14 @@ export const discordMessageActions: ChannelMessageActionAdapter = {
const accounts = listEnabledDiscordAccounts(cfg).filter(
(account) => account.tokenSource !== "none",
);
if (accounts.length === 0) return [];
if (accounts.length === 0) {
return [];
}
const gate = createActionGate(cfg.channels?.discord?.actions);
const actions = new Set<ChannelMessageActionName>(["send"]);
if (gate("polls")) actions.add("poll");
if (gate("polls")) {
actions.add("poll");
}
if (gate("reactions")) {
actions.add("react");
actions.add("reactions");
@@ -26,19 +30,35 @@ export const discordMessageActions: ChannelMessageActionAdapter = {
actions.add("unpin");
actions.add("list-pins");
}
if (gate("permissions")) actions.add("permissions");
if (gate("permissions")) {
actions.add("permissions");
}
if (gate("threads")) {
actions.add("thread-create");
actions.add("thread-list");
actions.add("thread-reply");
}
if (gate("search")) actions.add("search");
if (gate("stickers")) actions.add("sticker");
if (gate("memberInfo")) actions.add("member-info");
if (gate("roleInfo")) actions.add("role-info");
if (gate("reactions")) actions.add("emoji-list");
if (gate("emojiUploads")) actions.add("emoji-upload");
if (gate("stickerUploads")) actions.add("sticker-upload");
if (gate("search")) {
actions.add("search");
}
if (gate("stickers")) {
actions.add("sticker");
}
if (gate("memberInfo")) {
actions.add("member-info");
}
if (gate("roleInfo")) {
actions.add("role-info");
}
if (gate("reactions")) {
actions.add("emoji-list");
}
if (gate("emojiUploads")) {
actions.add("emoji-upload");
}
if (gate("stickerUploads")) {
actions.add("sticker-upload");
}
if (gate("roles", false)) {
actions.add("role-add");
actions.add("role-remove");
@@ -56,7 +76,9 @@ export const discordMessageActions: ChannelMessageActionAdapter = {
actions.add("category-edit");
actions.add("category-delete");
}
if (gate("voiceStatus")) actions.add("voice-status");
if (gate("voiceStatus")) {
actions.add("voice-status");
}
if (gate("events")) {
actions.add("event-list");
actions.add("event-create");

View File

@@ -12,8 +12,12 @@ import { resolveDiscordChannelId } from "../../../../discord/targets.js";
const providerId = "discord";
function readParentIdParam(params: Record<string, unknown>): string | null | undefined {
if (params.clearParent === true) return null;
if (params.parentId === null) return null;
if (params.clearParent === true) {
return null;
}
if (params.parentId === null) {
return null;
}
return readStringParam(params, "parentId");
}
@@ -219,7 +223,9 @@ export async function handleDiscordMessageAction(
resolveChannelId,
readParentIdParam,
});
if (adminResult !== undefined) return adminResult;
if (adminResult !== undefined) {
return adminResult;
}
throw new Error(`Action ${String(action)} is not supported for provider ${providerId}.`);
}

View File

@@ -9,9 +9,13 @@ const GROUP_PREFIX = "group:";
function normalizeSignalReactionRecipient(raw: string): string {
const trimmed = raw.trim();
if (!trimmed) return trimmed;
if (!trimmed) {
return trimmed;
}
const withoutSignal = trimmed.replace(/^signal:/i, "").trim();
if (!withoutSignal) return withoutSignal;
if (!withoutSignal) {
return withoutSignal;
}
if (withoutSignal.toLowerCase().startsWith("uuid:")) {
return withoutSignal.slice("uuid:".length).trim();
}
@@ -20,9 +24,13 @@ function normalizeSignalReactionRecipient(raw: string): string {
function resolveSignalReactionTarget(raw: string): { recipient?: string; groupId?: string } {
const trimmed = raw.trim();
if (!trimmed) return {};
if (!trimmed) {
return {};
}
const withoutSignal = trimmed.replace(/^signal:/i, "").trim();
if (!withoutSignal) return {};
if (!withoutSignal) {
return {};
}
if (withoutSignal.toLowerCase().startsWith(GROUP_PREFIX)) {
const groupId = withoutSignal.slice(GROUP_PREFIX.length).trim();
return groupId ? { groupId } : {};
@@ -33,9 +41,13 @@ function resolveSignalReactionTarget(raw: string): { recipient?: string; groupId
export const signalMessageActions: ChannelMessageActionAdapter = {
listActions: ({ cfg }) => {
const accounts = listEnabledSignalAccounts(cfg);
if (accounts.length === 0) return [];
if (accounts.length === 0) {
return [];
}
const configuredAccounts = accounts.filter((account) => account.configured);
if (configuredAccounts.length === 0) return [];
if (configuredAccounts.length === 0) {
return [];
}
const actions = new Set<ChannelMessageActionName>(["send"]);
@@ -105,7 +117,9 @@ export const signalMessageActions: ChannelMessageActionAdapter = {
}
if (remove) {
if (!emoji) throw new Error("Emoji required to remove reaction.");
if (!emoji) {
throw new Error("Emoji required to remove reaction.");
}
await removeReactionSignal(target.recipient ?? "", timestamp, emoji, {
accountId: accountId ?? undefined,
groupId: target.groupId,
@@ -115,7 +129,9 @@ export const signalMessageActions: ChannelMessageActionAdapter = {
return jsonResult({ ok: true, removed: emoji });
}
if (!emoji) throw new Error("Emoji required to add reaction.");
if (!emoji) {
throw new Error("Emoji required to add reaction.");
}
await sendReactionSignal(target.recipient ?? "", timestamp, emoji, {
accountId: accountId ?? undefined,
groupId: target.groupId,

View File

@@ -42,12 +42,20 @@ export const telegramMessageActions: ChannelMessageActionAdapter = {
const accounts = listEnabledTelegramAccounts(cfg).filter(
(account) => account.tokenSource !== "none",
);
if (accounts.length === 0) return [];
if (accounts.length === 0) {
return [];
}
const gate = createActionGate(cfg.channels?.telegram?.actions);
const actions = new Set<ChannelMessageActionName>(["send"]);
if (gate("reactions")) actions.add("react");
if (gate("deleteMessage")) actions.add("delete");
if (gate("editMessage")) actions.add("edit");
if (gate("reactions")) {
actions.add("react");
}
if (gate("deleteMessage")) {
actions.add("delete");
}
if (gate("editMessage")) {
actions.add("edit");
}
if (gate("sticker", false)) {
actions.add("sticker");
actions.add("sticker-search");
@@ -58,16 +66,22 @@ export const telegramMessageActions: ChannelMessageActionAdapter = {
const accounts = listEnabledTelegramAccounts(cfg).filter(
(account) => account.tokenSource !== "none",
);
if (accounts.length === 0) return false;
if (accounts.length === 0) {
return false;
}
return accounts.some((account) =>
isTelegramInlineButtonsEnabled({ cfg, accountId: account.accountId }),
);
},
extractToolSend: ({ args }) => {
const action = typeof args.action === "string" ? args.action.trim() : "";
if (action !== "sendMessage") return null;
if (action !== "sendMessage") {
return null;
}
const to = typeof args.to === "string" ? args.to : undefined;
if (!to) return null;
if (!to) {
return null;
}
const accountId = typeof args.accountId === "string" ? args.accountId.trim() : undefined;
return { to, accountId };
},