Compare commits
No commits in common. "main" and "old-javascript" have entirely different histories.
main
...
old-javasc
3 changed files with 7 additions and 15 deletions
|
@ -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.`);
|
|
@ -1,6 +1,2 @@
|
||||||
# TelegramBot-SpamWatch
|
# TelegramBot-SpamWatch
|
||||||
|
|
||||||
[](https://github.com/abocn/TelegramBot/blob/main/LICENSE)
|
|
||||||
[](https://www.typescriptlang.org)
|
|
||||||
|
|
||||||
Kowalski integration with the SpamWatch API (WIP)
|
Kowalski integration with the SpamWatch API (WIP)
|
||||||
|
|
|
@ -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 };
|
Loading…
Add table
Add a link
Reference in a new issue