fix: lint errors

This commit is contained in:
Bohdan Podvirnyi
2026-01-15 18:13:49 +02:00
committed by Peter Steinberger
parent 0e1dcf9cb4
commit eb7656d68c
10 changed files with 202 additions and 572 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -17,15 +17,8 @@ import {
resolveChannelGroupPolicy,
resolveChannelGroupRequireMention,
} from "../config/group-policy.js";
import {
loadSessionStore,
resolveStorePath,
updateLastRoute,
} from "../config/sessions.js";
import { loadSessionStore, resolveStorePath } from "../config/sessions.js";
import { danger, logVerbose, shouldLogVerbose } from "../globals.js";
import { recordChannelActivity } from "../infra/channel-activity.js";
import { createDedupeCache } from "../infra/dedupe.js";
import { formatErrorMessage } from "../infra/errors.js";
import { enqueueSystemEvent } from "../infra/system-events.js";
import { getChildLogger } from "../logging.js";
import { resolveAgentRoute } from "../routing/resolve-route.js";
@@ -47,12 +40,6 @@ import {
type TelegramUpdateKeyContext,
} from "./bot-updates.js";
import { resolveTelegramFetch } from "./fetch.js";
import {
readTelegramAllowFromStore,
upsertTelegramPairingRequest,
} from "./pairing-store.js";
import { wasSentByBot } from "./sent-message-cache.js";
import { resolveTelegramVoiceSend } from "./voice.js";
export type TelegramBotOptions = {
token: string;
@@ -334,23 +321,18 @@ export function createTelegramBot(opts: TelegramBotOptions) {
// Detect added reactions
const oldEmojis = new Set(
reaction.old_reaction
.filter(
(r): r is { type: "emoji"; emoji: string } => r.type === "emoji",
)
.filter((r): r is { type: "emoji"; emoji: string } => r.type === "emoji")
.map((r) => r.emoji),
);
const addedReactions = reaction.new_reaction
.filter(
(r): r is { type: "emoji"; emoji: string } => r.type === "emoji",
)
.filter((r): r is { type: "emoji"; emoji: string } => r.type === "emoji")
.filter((r) => !oldEmojis.has(r.emoji));
if (addedReactions.length === 0) return;
// Build sender label
const senderName = user
? [user.first_name, user.last_name].filter(Boolean).join(" ").trim() ||
user.username
? [user.first_name, user.last_name].filter(Boolean).join(" ").trim() || user.username
: undefined;
const senderUsername = user?.username ? `@${user.username}` : undefined;
let senderLabel = senderName;
@@ -373,11 +355,8 @@ export function createTelegramBot(opts: TelegramBotOptions) {
});
// Resolve agent route for session
const isGroup =
reaction.chat.type === "group" || reaction.chat.type === "supergroup";
const peerId = isGroup
? buildTelegramGroupPeerId(chatId, resolvedThreadId)
: String(chatId);
const isGroup = reaction.chat.type === "group" || reaction.chat.type === "supergroup";
const peerId = isGroup ? buildTelegramGroupPeerId(chatId, resolvedThreadId) : String(chatId);
const route = resolveAgentRoute({
cfg,
channel: "telegram",
@@ -396,9 +375,7 @@ export function createTelegramBot(opts: TelegramBotOptions) {
logVerbose(`telegram: reaction event enqueued: ${text}`);
}
} catch (err) {
runtime.error?.(
danger(`telegram reaction handler failed: ${String(err)}`),
);
runtime.error?.(danger(`telegram reaction handler failed: ${String(err)}`));
}
});

View File

@@ -34,10 +34,7 @@ export function createTelegramRunnerOptions(cfg: ClawdbotConfig): RunOptions<unk
// Match grammY defaults
timeout: 30,
// Request reaction updates from Telegram
allowed_updates: [
"message",
"message_reaction",
],
allowed_updates: ["message", "message_reaction"],
},
// Suppress grammY getUpdates stack traces; we log concise errors ourselves.
silent: true,

View File

@@ -24,8 +24,7 @@ export function resolveTelegramReactionLevel(params: {
cfg: params.cfg,
accountId: params.accountId,
});
const level = (account.config.reactionLevel ??
"ack") as TelegramReactionLevel;
const level = (account.config.reactionLevel ?? "ack") as TelegramReactionLevel;
switch (level) {
case "off":

View File

@@ -18,10 +18,7 @@ import { resolveTelegramAccount } from "./accounts.js";
import { resolveTelegramFetch } from "./fetch.js";
import { markdownToTelegramHtml } from "./format.js";
import { recordSentMessage } from "./sent-message-cache.js";
import {
parseTelegramTarget,
stripTelegramInternalPrefixes,
} from "./targets.js";
import { parseTelegramTarget, stripTelegramInternalPrefixes } from "./targets.js";
import { resolveTelegramVoiceSend } from "./voice.js";
type TelegramSendOpts = {

View File

@@ -1,9 +1,5 @@
import { afterEach, describe, expect, it } from "vitest";
import {
clearSentMessageCache,
recordSentMessage,
wasSentByBot,
} from "./sent-message-cache.js";
import { clearSentMessageCache, recordSentMessage, wasSentByBot } from "./sent-message-cache.js";
describe("sent-message-cache", () => {
afterEach(() => {

View File

@@ -29,10 +29,7 @@ function cleanupExpired(entry: CacheEntry): void {
/**
* Record a message ID as sent by the bot.
*/
export function recordSentMessage(
chatId: number | string,
messageId: number,
): void {
export function recordSentMessage(chatId: number | string, messageId: number): void {
const key = getChatKey(chatId);
let entry = sentMessages.get(key);
if (!entry) {
@@ -50,10 +47,7 @@ export function recordSentMessage(
/**
* Check if a message was sent by the bot.
*/
export function wasSentByBot(
chatId: number | string,
messageId: number,
): boolean {
export function wasSentByBot(chatId: number | string, messageId: number): boolean {
const key = getChatKey(chatId);
const entry = sentMessages.get(key);
if (!entry) return false;

View File

@@ -63,10 +63,7 @@ export async function startTelegramWebhook(opts: {
await bot.api.setWebhook(publicUrl, {
secret_token: opts.secret,
allowed_updates: [
"message",
"message_reaction",
],
allowed_updates: ["message", "message_reaction"],
});
await new Promise<void>((resolve) => server.listen(port, host, resolve));