mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 07:51:26 +00:00
chore: Enable more lint rules, disable some that trigger a lot. Will clean up later.
This commit is contained in:
@@ -37,7 +37,7 @@ export function listTelegramAccountIds(cfg: OpenClawConfig): string[] {
|
||||
);
|
||||
debugAccounts("listTelegramAccountIds", ids);
|
||||
if (ids.length === 0) return [DEFAULT_ACCOUNT_ID];
|
||||
return ids.sort((a, b) => a.localeCompare(b));
|
||||
return ids.toSorted((a, b) => a.localeCompare(b));
|
||||
}
|
||||
|
||||
export function resolveDefaultTelegramAccountId(cfg: OpenClawConfig): string {
|
||||
|
||||
@@ -59,8 +59,8 @@ export function collectTelegramUnmentionedGroupIds(
|
||||
for (const [key, value] of Object.entries(groups)) {
|
||||
if (key === "*") continue;
|
||||
if (!value || typeof value !== "object") continue;
|
||||
if ((value as TelegramGroupConfig).enabled === false) continue;
|
||||
if ((value as TelegramGroupConfig).requireMention !== false) continue;
|
||||
if (value.enabled === false) continue;
|
||||
if (value.requireMention !== false) continue;
|
||||
const id = String(key).trim();
|
||||
if (!id) continue;
|
||||
if (/^-?\d+$/.test(id)) {
|
||||
@@ -102,9 +102,9 @@ export async function auditTelegramGroupMembership(params: {
|
||||
const url = `${base}/getChatMember?chat_id=${encodeURIComponent(chatId)}&user_id=${encodeURIComponent(String(params.botId))}`;
|
||||
const res = await fetchWithTimeout(url, params.timeoutMs, fetcher);
|
||||
const json = (await res.json()) as TelegramApiOk<{ status?: string }> | TelegramApiErr;
|
||||
if (!res.ok || !isRecord(json) || json.ok !== true) {
|
||||
if (!res.ok || !isRecord(json) || !json.ok) {
|
||||
const desc =
|
||||
isRecord(json) && json.ok === false && typeof json.description === "string"
|
||||
isRecord(json) && !json.ok && typeof json.description === "string"
|
||||
? json.description
|
||||
: `getChatMember failed (${res.status})`;
|
||||
groups.push({
|
||||
|
||||
@@ -182,7 +182,7 @@ export function createTelegramBot(opts: TelegramBotOptions) {
|
||||
const MAX_RAW_UPDATE_STRING = 500;
|
||||
const MAX_RAW_UPDATE_ARRAY = 20;
|
||||
const stringifyUpdate = (update: unknown) => {
|
||||
const seen = new WeakSet<object>();
|
||||
const seen = new WeakSet();
|
||||
return JSON.stringify(update ?? null, (key, value) => {
|
||||
if (typeof value === "string" && value.length > MAX_RAW_UPDATE_STRING) {
|
||||
return `${value.slice(0, MAX_RAW_UPDATE_STRING)}...`;
|
||||
|
||||
@@ -140,7 +140,7 @@ export function expandTextLinks(text: string, entities?: TelegramTextLinkEntity[
|
||||
(entity): entity is TelegramTextLinkEntity & { url: string } =>
|
||||
entity.type === "text_link" && Boolean(entity.url),
|
||||
)
|
||||
.sort((a, b) => b.offset - a.offset);
|
||||
.toSorted((a, b) => b.offset - a.offset);
|
||||
|
||||
if (textLinks.length === 0) return text;
|
||||
|
||||
|
||||
@@ -105,8 +105,7 @@ export async function monitorTelegramProvider(opts: MonitorTelegramOpts = {}) {
|
||||
}
|
||||
|
||||
const proxyFetch =
|
||||
opts.proxyFetch ??
|
||||
(account.config.proxy ? makeProxyFetch(account.config.proxy as string) : undefined);
|
||||
opts.proxyFetch ?? (account.config.proxy ? makeProxyFetch(account.config.proxy) : undefined);
|
||||
|
||||
let lastUpdateId = await readTelegramUpdateOffset({
|
||||
accountId: account.accountId,
|
||||
|
||||
@@ -108,7 +108,7 @@ export function searchStickers(query: string, limit = 10): CachedSticker[] {
|
||||
}
|
||||
|
||||
return results
|
||||
.sort((a, b) => b.score - a.score)
|
||||
.toSorted((a, b) => b.score - a.score)
|
||||
.slice(0, limit)
|
||||
.map((r) => r.sticker);
|
||||
}
|
||||
@@ -130,7 +130,7 @@ export function getCacheStats(): { count: number; oldestAt?: string; newestAt?:
|
||||
if (stickers.length === 0) {
|
||||
return { count: 0 };
|
||||
}
|
||||
const sorted = [...stickers].sort(
|
||||
const sorted = [...stickers].toSorted(
|
||||
(a, b) => new Date(a.cachedAt).getTime() - new Date(b.cachedAt).getTime(),
|
||||
);
|
||||
return {
|
||||
|
||||
@@ -68,8 +68,8 @@ export async function startTelegramWebhook(opts: {
|
||||
logWebhookReceived({ channel: "telegram", updateType: "telegram-post" });
|
||||
}
|
||||
const handled = handler(req, res);
|
||||
if (handled && typeof (handled as Promise<void>).catch === "function") {
|
||||
void (handled as Promise<void>)
|
||||
if (handled && typeof handled.catch === "function") {
|
||||
void handled
|
||||
.then(() => {
|
||||
if (diagnosticsEnabled) {
|
||||
logWebhookProcessed({
|
||||
|
||||
Reference in New Issue
Block a user