Boto/node/boto.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-02-11 08:03:21 +00:00
// B O T O
2022-02-12 05:05:56 +00:00
2022-02-09 06:55:26 +00:00
require('dotenv').config();
2022-02-11 10:44:16 +00:00
const tmi = require('tmi.js');
2022-02-09 06:55:26 +00:00
console.log(process.env.API_HOST);
const client = new tmi.Client({
options: { debug: true },
connection: {
secure: true,
reconnect: true
},
identity: {
username: process.env.TTV_BOT_USERNAME,
password: process.env.TTV_BOT_OAUTH
},
channels: [ process.env.TTV_CHANNELS ]
});
client.connect();
2022-02-12 05:08:18 +00:00
// SCAN MSG | START
client.on('message', (channel, tags, message, self) => {
if(self) 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
2022-02-11 11:06:26 +00:00
2022-02-12 05:08:18 +00:00
if(self || !message.startsWith('!')) return; // Command Parser
const args = message.slice(1).split(' ');
const command = args.shift().toLowerCase(); // !COMMAND => command
2022-02-12 05:23:13 +00:00
else{
console.log(`Command not found`)
}
2022-02-12 05:17:08 +00:00
2022-02-12 05:14:10 +00:00
2022-02-12 05:08:18 +00:00
}); // SCAN MSG | END