Compare commits

..

No commits in common. "main" and "old-javascript" have entirely different histories.

3 changed files with 7 additions and 15 deletions

View file

@ -1,4 +1,4 @@
export default (isOnSpamWatch) => { module.exports = (isOnSpamWatch) => {
return async (ctx, next) => { return async (ctx, next) => {
if (await isOnSpamWatch(ctx.from.id)) { if (await isOnSpamWatch(ctx.from.id)) {
console.log(`User ${ctx.from.id} is banned on SpamWatch. Blocking command.`); console.log(`User ${ctx.from.id} is banned on SpamWatch. Blocking command.`);

View file

@ -1,6 +1,2 @@
# TelegramBot-SpamWatch # TelegramBot-SpamWatch
[![GitHub License](https://img.shields.io/github/license/abocn/TelegramBot)](https://github.com/abocn/TelegramBot/blob/main/LICENSE)
[![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=fff)](https://www.typescriptlang.org)
Kowalski integration with the SpamWatch API (WIP) Kowalski integration with the SpamWatch API (WIP)

View file

@ -1,9 +1,9 @@
import fs from 'fs'; const fs = require('fs');
import path from 'path'; const path = require('path');
const blocklistPath = path.join(__dirname, 'sw_blocklist.txt'); const blocklistPath = path.join(__dirname, 'sw_blocklist.txt');
let blocklist: string[] = []; let blocklist = [];
const readBlocklist = () => { const readBlocklist = () => {
try { try {
@ -19,14 +19,10 @@ const readBlocklist = () => {
} }
}; };
const isOnSpamWatch = (userId: string) => { const isOnSpamWatch = (userId) => {
return blocklist.includes(userId); return blocklist.includes(String(userId));
}; };
const isSpamwatchConnected = () => blocklist.length > 0;
const getSpamwatchBlockedCount = () => blocklist.length;
readBlocklist(); readBlocklist();
export { isOnSpamWatch, isSpamwatchConnected, getSpamwatchBlockedCount }; module.exports = { isOnSpamWatch };