This commit is contained in:
2026-05-13 10:18:54 +03:00
parent cd8d2683c0
commit c5b61ee3d8
38 changed files with 3929 additions and 3718 deletions
+10 -11
View File
@@ -1,4 +1,5 @@
import * as si from "systeminformation";
import {redactLogValue} from "../ai/ai-logger";
import {Command} from "../base/command";
import {CallbackCommand} from "../base/callback-command";
import {
@@ -65,7 +66,7 @@ export const ignoreIfMarkupFailed = (e: Error | TelegramError) => {
};
export const logError = (e: Error | TelegramError | string | unknown) => {
console.error(e);
console.error(redactLogValue(e));
};
export const errorPlaceholder = async (msg: Message) => {
@@ -307,13 +308,13 @@ export async function editMessageText(options: EditOptions, retries = 1) {
}
);
return Promise.resolve(message);
} catch (e: any) {
} catch (e: unknown) {
logError(e);
if (isMarkupFailed(e)) {
if (isMarkupFailed(e as Error | TelegramError)) {
return Promise.resolve(true);
} else if (isTooManyRequests(e) && retries > 0) {
const retryAfter = Number(e.message.split("retry after ")[1]) || 30;
} else if (isTooManyRequests(e as Error | TelegramError) && retries > 0) {
const retryAfter = Number((e instanceof Error ? e.message : String(e)).split("retry after ")[1]) || 30;
await delay(retryAfter * 1000);
return editMessageText(options, retries - 1);
} else {
@@ -1836,9 +1837,10 @@ export function startIntervalEditor(params: {
try {
await params.editFn(next);
lastSent = next;
} catch (e: any) {
if ((e?.description ?? e?.message ?? "").includes("message is not modified")) return;
logError("edit failed: " + e);
} catch (e: unknown) {
const description = e instanceof Error ? e.message : String(e);
if (description.includes("message is not modified")) return;
logError("edit failed: " + description);
}
};
@@ -1896,7 +1898,6 @@ type RuntimeInfo =
| { runtime: "unknown"; version: string };
export function getRuntimeInfo(): RuntimeInfo {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const v = process.versions ?? {};
if (typeof v.bun === "string") {
@@ -1906,7 +1907,6 @@ export function getRuntimeInfo(): RuntimeInfo {
return {runtime: "node", version: v.node};
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return {runtime: "unknown", version: String(process.version ?? "")};
}
@@ -1957,7 +1957,6 @@ export async function imageToBase64(filePath: string, withMimeType: boolean = fa
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function ifTrue(exp?: string | number | boolean): boolean {
if (!exp) return false;