chore: Lint extensions folder.

This commit is contained in:
cpojer
2026-01-31 22:13:48 +09:00
parent 4f2166c503
commit 230ca789e2
221 changed files with 4006 additions and 1583 deletions

View File

@@ -38,7 +38,9 @@ function buildLineReply(lineData: LineChannelData): ReplyPayload {
* Data can be a URL (uri action) or plain text (message action) or key=value (postback)
*/
function parseActions(actionsStr: string | undefined): CardAction[] {
if (!actionsStr) return [];
if (!actionsStr) {
return [];
}
const results: CardAction[] = [];
@@ -47,7 +49,9 @@ function parseActions(actionsStr: string | undefined): CardAction[] {
.trim()
.split("|")
.map((s) => s.trim());
if (!label) continue;
if (!label) {
continue;
}
const actionData = data || label;
@@ -158,12 +162,16 @@ export function registerLineCardCommand(api: OpenClawPluginApi): void {
requireAuth: false,
handler: async (ctx) => {
const argsStr = ctx.args?.trim() ?? "";
if (!argsStr) return { text: CARD_USAGE };
if (!argsStr) {
return { text: CARD_USAGE };
}
const parsed = parseCardArgs(argsStr);
const { type, args, flags } = parsed;
if (!type) return { text: CARD_USAGE };
if (!type) {
return { text: CARD_USAGE };
}
// Only LINE supports rich cards; fallback to text elsewhere.
if (ctx.channel !== "line") {

View File

@@ -25,17 +25,6 @@ const meta = {
systemImage: "message.fill",
};
function parseThreadId(threadId?: string | number | null): number | undefined {
if (threadId == null) return undefined;
if (typeof threadId === "number") {
return Number.isFinite(threadId) ? Math.trunc(threadId) : undefined;
}
const trimmed = threadId.trim();
if (!trimmed) return undefined;
const parsed = Number.parseInt(trimmed, 10);
return Number.isFinite(parsed) ? parsed : undefined;
}
export const linePlugin: ChannelPlugin<ResolvedLineAccount> = {
id: "line",
meta: {
@@ -108,7 +97,8 @@ export const linePlugin: ChannelPlugin<ResolvedLineAccount> = {
deleteAccount: ({ cfg, accountId }) => {
const lineConfig = (cfg.channels?.line ?? {}) as LineConfig;
if (accountId === DEFAULT_ACCOUNT_ID) {
const { channelAccessToken, channelSecret, tokenFile, secretFile, ...rest } = lineConfig;
// oxlint-disable-next-line no-unused-vars
const { channelSecret, tokenFile, secretFile, ...rest } = lineConfig;
return {
...cfg,
channels: {
@@ -173,7 +163,9 @@ export const linePlugin: ChannelPlugin<ResolvedLineAccount> = {
const defaultGroupPolicy = (cfg.channels?.defaults as { groupPolicy?: string } | undefined)
?.groupPolicy;
const groupPolicy = account.config.groupPolicy ?? defaultGroupPolicy ?? "allowlist";
if (groupPolicy !== "open") return [];
if (groupPolicy !== "open") {
return [];
}
return [
`- LINE groups: groupPolicy="open" allows any member in groups to trigger. Set channels.line.groupPolicy="allowlist" + channels.line.groupAllowFrom to restrict senders.`,
];
@@ -183,7 +175,9 @@ export const linePlugin: ChannelPlugin<ResolvedLineAccount> = {
resolveRequireMention: ({ cfg, accountId, groupId }) => {
const account = getLineRuntime().channel.line.resolveLineAccount({ cfg, accountId });
const groups = account.config.groups;
if (!groups) return false;
if (!groups) {
return false;
}
const groupConfig = groups[groupId] ?? groups["*"];
return groupConfig?.requireMention ?? false;
},
@@ -191,13 +185,17 @@ export const linePlugin: ChannelPlugin<ResolvedLineAccount> = {
messaging: {
normalizeTarget: (target) => {
const trimmed = target.trim();
if (!trimmed) return null;
if (!trimmed) {
return null;
}
return trimmed.replace(/^line:(group|room|user):/i, "").replace(/^line:/i, "");
},
targetResolver: {
looksLikeId: (id) => {
const trimmed = id?.trim();
if (!trimmed) return false;
if (!trimmed) {
return false;
}
// LINE user IDs are typically U followed by 32 hex characters
// Group IDs are C followed by 32 hex characters
// Room IDs are R followed by 32 hex characters
@@ -356,7 +354,9 @@ export const linePlugin: ChannelPlugin<ResolvedLineAccount> = {
: undefined;
const sendMessageBatch = async (messages: Array<Record<string, unknown>>) => {
if (messages.length === 0) return;
if (messages.length === 0) {
return;
}
for (let i = 0; i < messages.length; i += 5) {
const result = await sendBatch(to, messages.slice(i, i + 5), {
verbose: false,
@@ -434,12 +434,12 @@ export const linePlugin: ChannelPlugin<ResolvedLineAccount> = {
for (let i = 0; i < chunks.length; i += 1) {
const isLast = i === chunks.length - 1;
if (isLast && hasQuickReplies) {
lastResult = await sendQuickReplies(to, chunks[i]!, lineData.quickReplies!, {
lastResult = await sendQuickReplies(to, chunks[i], lineData.quickReplies!, {
verbose: false,
accountId: accountId ?? undefined,
});
} else {
lastResult = await sendText(to, chunks[i]!, {
lastResult = await sendText(to, chunks[i], {
verbose: false,
accountId: accountId ?? undefined,
});
@@ -478,7 +478,9 @@ export const linePlugin: ChannelPlugin<ResolvedLineAccount> = {
}
for (const url of mediaUrls) {
const trimmed = url?.trim();
if (!trimmed) continue;
if (!trimmed) {
continue;
}
quickReplyMessages.push({
type: "image",
originalContentUrl: trimmed,
@@ -505,7 +507,9 @@ export const linePlugin: ChannelPlugin<ResolvedLineAccount> = {
}
}
if (lastResult) return { channel: "line", ...lastResult };
if (lastResult) {
return { channel: "line", ...lastResult };
}
return { channel: "line", messageId: "empty", chatId: to };
},
sendText: async ({ to, text, accountId }) => {
@@ -621,7 +625,9 @@ export const linePlugin: ChannelPlugin<ResolvedLineAccount> = {
try {
const probe = await getLineRuntime().channel.line.probeLineBot(token, 2500);
const displayName = probe.ok ? probe.bot?.displayName?.trim() : null;
if (displayName) lineBotLabel = ` (${displayName})`;
if (displayName) {
lineBotLabel = ` (${displayName})`;
}
} catch (err) {
if (getLineRuntime().logging.shouldLogVerbose()) {
ctx.log?.debug?.(`[${account.accountId}] bot probe failed: ${String(err)}`);