fix lint
This commit is contained in:
parent
d32ed657a1
commit
69695e265a
5 changed files with 15 additions and 15 deletions
|
|
@ -43,14 +43,14 @@ if (cli["include-peers"] && cli["exclude-peers"]) {
|
||||||
if (cli["include-peers"]) {
|
if (cli["include-peers"]) {
|
||||||
config.includePeers = [];
|
config.includePeers = [];
|
||||||
for (const o of cli["include-peers"] as string[]) {
|
for (const o of cli["include-peers"] as string[]) {
|
||||||
config.includePeers.push(...o.split(",").map(i => parseInt(i)).filter(i => !isNaN(i)));
|
config.includePeers.push(...o.split(",").map(i => Number.parseInt(i)).filter(i => !Number.isNaN(i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cli["exclude-peers"]) {
|
if (cli["exclude-peers"]) {
|
||||||
config.excludePeers = [];
|
config.excludePeers = [];
|
||||||
for (const o of cli["exclude-peers"] as string[]) {
|
for (const o of cli["exclude-peers"] as string[]) {
|
||||||
config.excludePeers.push(...o.split(",").map(i => parseInt(i)).filter(i => !isNaN(i)));
|
config.excludePeers.push(...o.split(",").map(i => Number.parseInt(i)).filter(i => !Number.isNaN(i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
|
import type { Configuration } from "./config.js";
|
||||||
import { filters } from "@mtcute/dispatcher";
|
import { filters } from "@mtcute/dispatcher";
|
||||||
import { Configuration } from "./config.js";
|
|
||||||
|
|
||||||
export function peersConfigBoolFilter(conf: Configuration, peerId: number) {
|
export function peersConfigBoolFilter(conf: Configuration, peerId: number) {
|
||||||
if(conf.excludePeers && conf.excludePeers.indexOf(peerId) !== -1) {
|
if (conf.excludePeers && conf.excludePeers.includes(peerId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(conf.includePeers && conf.includePeers.indexOf(peerId) === -1) {
|
if (conf.includePeers && !conf.includePeers.includes(peerId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function peersConfigFilter(conf: Configuration) {
|
export function peersConfigFilter(conf: Configuration) {
|
||||||
if(conf.excludePeers) {
|
if (conf.excludePeers) {
|
||||||
return filters.not(filters.chatId(conf.excludePeers));
|
return filters.not(filters.chatId(conf.excludePeers));
|
||||||
} else if (conf.includePeers) {
|
} else if (conf.includePeers) {
|
||||||
return filters.chatId(conf.includePeers);
|
return filters.chatId(conf.includePeers);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import type { Dispatcher } from "@mtcute/dispatcher";
|
import type { Dispatcher } from "@mtcute/dispatcher";
|
||||||
import { PropagationAction } from "@mtcute/dispatcher";
|
import { PropagationAction } from "@mtcute/dispatcher";
|
||||||
import { Counter } from "prom-client";
|
import { Counter } from "prom-client";
|
||||||
import { peersConfigFilter } from "./filters.js";
|
|
||||||
import { config } from "./config.js";
|
import { config } from "./config.js";
|
||||||
|
import { peersConfigFilter } from "./filters.js";
|
||||||
|
|
||||||
interface KeywordPattern {
|
interface KeywordPattern {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@ import type { TelegramClient } from "@mtcute/node";
|
||||||
import { PropagationAction } from "@mtcute/dispatcher";
|
import { PropagationAction } from "@mtcute/dispatcher";
|
||||||
import { Counter, Gauge } from "prom-client";
|
import { Counter, Gauge } from "prom-client";
|
||||||
|
|
||||||
import { KeywordsCounter, newWordsCounter } from "./keywords.js";
|
|
||||||
import { config } from "./config.js";
|
import { config } from "./config.js";
|
||||||
import { peersConfigBoolFilter, peersConfigFilter } from "./filters.js";
|
import { peersConfigBoolFilter, peersConfigFilter } from "./filters.js";
|
||||||
|
import { KeywordsCounter, newWordsCounter } from "./keywords.js";
|
||||||
|
|
||||||
function newMessagesCounter(dp: Dispatcher) {
|
function newMessagesCounter(dp: Dispatcher) {
|
||||||
const counter = new Counter({
|
const counter = new Counter({
|
||||||
|
|
@ -31,7 +31,7 @@ function newStaticPeerInfoGauge(tg: TelegramClient) {
|
||||||
collect: async () => {
|
collect: async () => {
|
||||||
gauge.reset();
|
gauge.reset();
|
||||||
for await (const d of tg.iterDialogs()) {
|
for await (const d of tg.iterDialogs()) {
|
||||||
if(!peersConfigBoolFilter(config, d.peer.id)) {
|
if (!peersConfigBoolFilter(config, d.peer.id)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,7 +54,7 @@ function newUnreadCountGauge(tg: TelegramClient) {
|
||||||
collect: async () => {
|
collect: async () => {
|
||||||
gauge.reset();
|
gauge.reset();
|
||||||
for await (const d of tg.iterDialogs()) {
|
for await (const d of tg.iterDialogs()) {
|
||||||
if(!peersConfigBoolFilter(config, d.peer.id)) {
|
if (!peersConfigBoolFilter(config, d.peer.id)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue