mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 04:39:57 +00:00
Implement SpamWatch API banlist with Middleware and submodules
This commit is contained in:
parent
11653201db
commit
e84a16eb03
5
bot.js
5
bot.js
@ -1,5 +1,6 @@
|
||||
const { Telegraf } = require('telegraf');
|
||||
const Config = require('./props/config.json');
|
||||
const { isOnSpamWatch } = require('./plugins/lib-spamwatch/spamwatch.js');
|
||||
|
||||
const bot = new Telegraf(Config.botToken);
|
||||
|
||||
@ -11,8 +12,8 @@ const loadCommands = () => {
|
||||
fs.readdirSync(commandsPath).forEach((file) => {
|
||||
const command = require(path.join(commandsPath, file));
|
||||
if (typeof command === 'function') {
|
||||
command(bot);
|
||||
};
|
||||
command(bot, isOnSpamWatch);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
const Config = require('../props/config.json');
|
||||
const { getStrings } = require('../plugins/checklang.js');
|
||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||
|
||||
async function collectInfo(ctx) {
|
||||
const Strings = getStrings(ctx.from.language_code);
|
||||
@ -14,7 +16,7 @@ async function collectInfo(ctx) {
|
||||
}
|
||||
|
||||
module.exports = (bot) => {
|
||||
bot.command('ban', async (ctx) => {
|
||||
bot.command('ban', spamwatchMiddleware, async (ctx) => {
|
||||
const info = await collectInfo(ctx);
|
||||
const { Strings, chatId, userId, isAdmin, onCrew } = info;
|
||||
|
||||
@ -56,7 +58,7 @@ module.exports = (bot) => {
|
||||
};
|
||||
});
|
||||
|
||||
bot.command('unban', async (ctx) => {
|
||||
bot.command('unban', spamwatchMiddleware, async (ctx) => {
|
||||
const info = await collectInfo(ctx);
|
||||
const { Strings, chatId, userId, isAdmin, onCrew } = info;
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
// specific commands to the crew
|
||||
const Config = require('../props/config.json');
|
||||
const { getStrings } = require('../plugins/checklang.js');
|
||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||
const os = require('os');
|
||||
|
||||
function formatUptime(uptime) {
|
||||
@ -34,7 +36,7 @@ function getSystemInfo() {
|
||||
}
|
||||
|
||||
module.exports = (bot) => {
|
||||
bot.command('getbotstats', (ctx) => {
|
||||
bot.command('getbotstats', spamwatchMiddleware, async (ctx) => {
|
||||
const Strings = getStrings(ctx.from.language_code);
|
||||
const userId = ctx.from.id || Strings.unKnown;
|
||||
if (Config.admins.includes(userId)) {
|
||||
@ -56,7 +58,7 @@ module.exports = (bot) => {
|
||||
}
|
||||
});
|
||||
|
||||
bot.command('setbotname', (ctx) => {
|
||||
bot.command('setbotname', spamwatchMiddleware, async (ctx) => {
|
||||
const Strings = getStrings(ctx.from.language_code);
|
||||
const userId = ctx.from.id || Strings.unKnown;
|
||||
if (Config.admins.includes(userId)) {
|
||||
@ -73,7 +75,7 @@ module.exports = (bot) => {
|
||||
}
|
||||
});
|
||||
|
||||
bot.command('setbotdesc', (ctx) => {
|
||||
bot.command('setbotdesc', spamwatchMiddleware, async (ctx) => {
|
||||
const Strings = getStrings(ctx.from.language_code);
|
||||
const userId = ctx.from.id || Strings.unKnown;
|
||||
if (Config.admins.includes(userId)) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
const resources = require('../props/resources.json');
|
||||
const { getStrings } = require('../plugins/checklang.js');
|
||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||
|
||||
function furryFunction(ctx) {
|
||||
const Strings = getStrings(ctx.from.language_code);
|
||||
@ -42,7 +44,7 @@ function gayFunction(ctx) {
|
||||
}
|
||||
|
||||
module.exports = (bot) => {
|
||||
bot.command('dice', async (ctx) => {
|
||||
bot.command('dice', spamwatchMiddleware, async (ctx) => {
|
||||
ctx.telegram.sendDice(
|
||||
ctx.chat.id, {
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
@ -50,7 +52,7 @@ module.exports = (bot) => {
|
||||
);
|
||||
});
|
||||
|
||||
bot.command('slot', async (ctx) => {
|
||||
bot.command('slot', spamwatchMiddleware, async (ctx) => {
|
||||
ctx.telegram.sendDice(
|
||||
ctx.chat.id, {
|
||||
emoji: '🎰',
|
||||
@ -59,11 +61,11 @@ module.exports = (bot) => {
|
||||
);
|
||||
});
|
||||
|
||||
bot.command('furry', (ctx) => {
|
||||
bot.command('furry', spamwatchMiddleware, async (ctx) => {
|
||||
furryFunction(ctx);
|
||||
});
|
||||
|
||||
bot.command('gay', (ctx) => {
|
||||
bot.command('gay', spamwatchMiddleware, async (ctx) => {
|
||||
gayFunction(ctx);
|
||||
});
|
||||
};
|
@ -1,4 +1,6 @@
|
||||
const { getStrings } = require('../plugins/checklang.js');
|
||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||
|
||||
async function getUserInfo(ctx) {
|
||||
const Strings = getStrings(ctx.from.language_code);
|
||||
@ -54,7 +56,7 @@ async function getChatInfo(ctx) {
|
||||
}
|
||||
|
||||
module.exports = (bot) => {
|
||||
bot.command('chatinfo', async (ctx) => {
|
||||
bot.command('chatinfo', spamwatchMiddleware, async (ctx) => {
|
||||
const chatInfo = await getChatInfo(ctx);
|
||||
ctx.reply(
|
||||
chatInfo, {
|
||||
@ -64,7 +66,7 @@ module.exports = (bot) => {
|
||||
);
|
||||
});
|
||||
|
||||
bot.command('userinfo', async (ctx) => {
|
||||
bot.command('userinfo', spamwatchMiddleware, async (ctx) => {
|
||||
const userInfo = await getUserInfo(ctx);
|
||||
ctx.reply(
|
||||
userInfo, {
|
||||
|
@ -1,8 +1,10 @@
|
||||
const { getStrings } = require('../plugins/checklang.js');
|
||||
const resources = require('../props/resources.json');
|
||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||
|
||||
module.exports = (bot) => {
|
||||
bot.help((ctx) => {
|
||||
bot.help(spamwatchMiddleware, async (ctx) => {
|
||||
const Strings = getStrings(ctx.from.language_code);
|
||||
ctx.replyWithPhoto(
|
||||
resources.lunaCat2, {
|
||||
|
@ -1,7 +1,9 @@
|
||||
const { getStrings } = require('../plugins/checklang.js');
|
||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||
|
||||
module.exports = (bot) => {
|
||||
bot.command('privacy', (ctx) => {
|
||||
bot.command('privacy', spamwatchMiddleware, async (ctx) => {
|
||||
const Strings = getStrings(ctx.from.language_code);
|
||||
ctx.reply(
|
||||
Strings.lynxPrivacy, {
|
||||
|
@ -1,11 +1,13 @@
|
||||
const { getStrings } = require('../plugins/checklang.js');
|
||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||
|
||||
function getRandomInt(max) {
|
||||
return Math.floor(Math.random() * max);
|
||||
}
|
||||
|
||||
module.exports = (bot) => {
|
||||
bot.command('random', (ctx) => {
|
||||
bot.command('random', spamwatchMiddleware, async (ctx) => {
|
||||
const Strings = getStrings(ctx.from.language_code);
|
||||
const randomValue = getRandomInt(11);
|
||||
const randomVStr = Strings.randomNum.replace('{number}', randomValue);
|
||||
|
@ -1,8 +1,10 @@
|
||||
const resources = require('../props/resources.json');
|
||||
const { getStrings } = require('../plugins/checklang.js');
|
||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||
|
||||
module.exports = (bot) => {
|
||||
bot.start((ctx) => {
|
||||
bot.start(spamwatchMiddleware, async (ctx) => {
|
||||
const Strings = getStrings(ctx.from.language_code);
|
||||
ctx.replyWithPhoto(
|
||||
resources.lunaCat, {
|
||||
|
Loading…
x
Reference in New Issue
Block a user