From 3ecd084d4431c06b94dc74a83c3687234542207e Mon Sep 17 00:00:00 2001 From: Aidan Date: Thu, 24 Apr 2025 18:50:00 -0400 Subject: [PATCH] rf: js -> ts --- Middleware.js => Middleware.ts | 2 +- spamwatch.js => spamwatch.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) rename Middleware.js => Middleware.ts (84%) rename spamwatch.js => spamwatch.ts (76%) diff --git a/Middleware.js b/Middleware.ts similarity index 84% rename from Middleware.js rename to Middleware.ts index 5e22c04..9586d52 100644 --- a/Middleware.js +++ b/Middleware.ts @@ -1,4 +1,4 @@ -module.exports = (isOnSpamWatch) => { +export default (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/spamwatch.js b/spamwatch.ts similarity index 76% rename from spamwatch.js rename to spamwatch.ts index 8428828..050b006 100644 --- a/spamwatch.js +++ b/spamwatch.ts @@ -1,9 +1,9 @@ -const fs = require('fs'); -const path = require('path'); +import fs from 'fs'; +import path from 'path'; const blocklistPath = path.join(__dirname, 'sw_blocklist.txt'); -let blocklist = []; +let blocklist: string[] = []; const readBlocklist = () => { try { @@ -19,10 +19,10 @@ const readBlocklist = () => { } }; -const isOnSpamWatch = (userId) => { - return blocklist.includes(String(userId)); +const isOnSpamWatch = (userId: string) => { + return blocklist.includes(userId); }; readBlocklist(); -module.exports = { isOnSpamWatch }; +export { isOnSpamWatch };