This commit is contained in:
soffee 2025-04-08 13:42:47 +03:00
parent d32ed657a1
commit 69695e265a
5 changed files with 15 additions and 15 deletions

View file

@ -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)));
} }
} }

View file

@ -1,11 +1,11 @@
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;

View file

@ -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;

View file

@ -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({