Update 'node/autoban.js'

This commit is contained in:
Sarimoko 2022-02-16 18:55:19 +00:00
parent 60be66c22a
commit 06c00adadf
1 changed files with 22 additions and 4 deletions

View File

@ -3,11 +3,13 @@ const tmi = require('tmi.js');
const colors = require('colors');
const config = require("./db/lurk_bots");
// Define DB pull
const {banlist} = lurk_bots
console.log(`ANTI / Lurk Bots`.black.bgBrightRed);
console.log(`v 0.1 | BETA`.black.bgBrightRed);
console.log(process.env.API_HOST);
console.log(`Loading... | Lurk Bot DB`.black.bgGreen);
const {botlist} = lurk_bots
console.log(`Loading... | Setting from .env file`.black.bgGreen);
const client = new tmi.Client({
options: { debug: true },
connection: {
@ -21,7 +23,23 @@ const client = new tmi.Client({
channels: [ process.env.TTV_STREAMER_CHANNEL ]
});
console.log(`Loading... | TTV IRC Login`.black.bgGreen);
client.connect();
console.log(`Loading... | Chatbot`.black.bgGreen);
client.on('message', (channel, tags, message, self) => {
if(botlist) return;
const badges = tags.badges || {}; // Scan Badges
const isBroadcaster = badges.broadcaster; // Define Streamer
const isMod = badges.moderator; // Define Mod
const isModUp = isBroadcaster || isMod; // Permission Merge = Mod+Streamer
const isSub = badges.subscriber || badges.founder; // Define Subs
const botUserState = client.userstate[channel]; // MOD Status Check
const amMod = botUserState !== undefined && botUserState.mod === true; // Define Mod Status
if(self || !message.startsWith('!')) return; // Command Parser
const args = message.slice(1).split(' ');
const command = args.shift().toLowerCase(); // !COMMAND => command
// Ban function
// Ban function
console.log(process.env.API_HOST);