diff --git a/Middleware.ts b/Middleware.js similarity index 84% rename from Middleware.ts rename to Middleware.js index 9586d52..5e22c04 100644 --- a/Middleware.ts +++ b/Middleware.js @@ -1,4 +1,4 @@ -export default (isOnSpamWatch) => { +module.exports = (isOnSpamWatch) => { return async (ctx, next) => { if (await isOnSpamWatch(ctx.from.id)) { console.log(`User ${ctx.from.id} is banned on SpamWatch. Blocking command.`); diff --git a/README.md b/README.md index 4931cf1..16edc68 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,2 @@ # 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) diff --git a/spamwatch.ts b/spamwatch.js similarity index 64% rename from spamwatch.ts rename to spamwatch.js index ec7a054..8428828 100644 --- a/spamwatch.ts +++ b/spamwatch.js @@ -1,9 +1,9 @@ -import fs from 'fs'; -import path from 'path'; +const fs = require('fs'); +const path = require('path'); const blocklistPath = path.join(__dirname, 'sw_blocklist.txt'); -let blocklist: string[] = []; +let blocklist = []; const readBlocklist = () => { try { @@ -19,14 +19,10 @@ const readBlocklist = () => { } }; -const isOnSpamWatch = (userId: string) => { - return blocklist.includes(userId); +const isOnSpamWatch = (userId) => { + return blocklist.includes(String(userId)); }; -const isSpamwatchConnected = () => blocklist.length > 0; - -const getSpamwatchBlockedCount = () => blocklist.length; - readBlocklist(); -export { isOnSpamWatch, isSpamwatchConnected, getSpamwatchBlockedCount }; +module.exports = { isOnSpamWatch };