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) => {
if (await isOnSpamWatch(ctx.from.id)) {
console.log(`User ${ctx.from.id} is banned on SpamWatch. Blocking command.`);

View file

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

View file

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