Update 'node/chatbot.js'
This commit is contained in:
parent
a756202f6a
commit
34054127b4
|
@ -1,12 +1,14 @@
|
|||
// GAME NGIN | MMOIRC
|
||||
// Heyo / TMI_js by Sarimoko.com
|
||||
// ================================
|
||||
// Inside Twitch Chat an adventure is growing!
|
||||
// Hello World Chatbot for Twitch IRC using TMI.js!
|
||||
// --------------------------------
|
||||
// View README.md for .env setup!!!
|
||||
// --------------------------------
|
||||
require('dotenv').config();
|
||||
const tmi = require('tmi.js');
|
||||
var mysql = require('mysql'); // MySQL is optional
|
||||
// MySQL Connection
|
||||
// MySQL Setup | Optional - View README.md for MySQL setup!
|
||||
// --------------------------------
|
||||
var mysql = require('mysql');
|
||||
var con = mysql.createConnection({
|
||||
host: process.env.SQL_IP, // Add in DOTenv
|
||||
user: process.env.SQL_USER, // Add in DOTenv
|
||||
|
@ -18,13 +20,9 @@ con.connect(function(err) {
|
|||
if (err) throw err;
|
||||
console.log("MySQL | Connected!");
|
||||
});
|
||||
|
||||
// TMI Config
|
||||
// --------------------------------
|
||||
console.log(process.env.API_HOST);
|
||||
|
||||
// TMI Init
|
||||
// --------------------------------
|
||||
const client = new tmi.Client({
|
||||
options: { debug: true },
|
||||
connection: {
|
||||
|
@ -37,11 +35,9 @@ const client = new tmi.Client({
|
|||
},
|
||||
channels: [ process.env.TTV_CHANNELS ] // Add in DOTenv
|
||||
});
|
||||
|
||||
// TTV IRC Connect
|
||||
// --------------------------------
|
||||
client.connect();
|
||||
|
||||
// Mod Setup
|
||||
// ================================
|
||||
// isMod = Broadcaster/Streamer & Mods
|
||||
|
@ -55,92 +51,95 @@ client.on('message', (channel, tags, message, self) => {
|
|||
});
|
||||
// Channel Reactions
|
||||
// ================================
|
||||
// Anon Gifted Sub Upgraded to Paid
|
||||
// When an Anonymous Gift-Sub is Upgraded to Paid by the gifted user.
|
||||
// --------------------------------
|
||||
client.on("anongiftpaidupgrade", (channel, username, userstate) => {
|
||||
client.say(channel, `/me Hello World!`);
|
||||
});
|
||||
// Anon Gifted Sub Upgraded to Paid
|
||||
// When a User is BANNED
|
||||
// --------------------------------
|
||||
client.on("ban", (channel, username, reason, userstate) => {
|
||||
client.say(channel, `/me Hello World!`);
|
||||
});
|
||||
// Anon Gifted Sub Upgraded to Paid
|
||||
// When Bits are Cheered
|
||||
// --------------------------------
|
||||
client.on("cheer", (channel, userstate, message) => {
|
||||
client.say(channel, `/me Hello World!`);
|
||||
});
|
||||
// Anon Gifted Sub Upgraded to Paid
|
||||
// After Chat is Cleared by a MOD
|
||||
// --------------------------------
|
||||
client.on("clearchat", (channel) => {
|
||||
client.say(channel, `/me Hello World!`);
|
||||
});
|
||||
// Anon Gifted Sub Upgraded to Paid
|
||||
// When a Gift-Sub is Upgraded to Paid by the gifted user.
|
||||
// --------------------------------
|
||||
client.on("giftpaidupgrade", (channel, username, sender, userstate) => {
|
||||
client.say(channel, `/me Hello World!`);
|
||||
});
|
||||
// Anon Gifted Sub Upgraded to Paid
|
||||
// When @someone Hosts your channel
|
||||
// --------------------------------
|
||||
client.on("hosting", (channel, target, viewers) => {
|
||||
client.say(channel, `/me Hello World!`);
|
||||
});
|
||||
// Anon Gifted Sub Upgraded to Paid
|
||||
// When @someone connects to your Twitch IRC
|
||||
// --------------------------------
|
||||
// DOES NOT COUNT AS VIEWER!
|
||||
// *** WARNING: Annoying AF don't really use it! I've commented it out.
|
||||
client.on("join", (channel, username, self) => {
|
||||
client.say(channel, `/me Hello World!`);
|
||||
// client.say(channel, `/me Hello World!`);
|
||||
});
|
||||
// Anon Gifted Sub Upgraded to Paid
|
||||
// When @someone dis-connects from your Twitch IRC
|
||||
// --------------------------------
|
||||
// BYE FELICIA!
|
||||
// *** WARNING: Annoying AF don't really use it! I've commented it out.
|
||||
client.on("part", (channel, username, self) => {
|
||||
client.say(channel, `/me Hello World!`);
|
||||
// client.say(channel, `/me Hello World!`);
|
||||
});
|
||||
// Anon Gifted Sub Upgraded to Paid
|
||||
// When @someone Raids your Channel
|
||||
// --------------------------------
|
||||
client.on("raided", (channel, username, viewers) => {
|
||||
client.say(channel, `/me Hello World!`);
|
||||
});
|
||||
// Anon Gifted Sub Upgraded to Paid
|
||||
// When @someone Gifts a Sub
|
||||
// --------------------------------
|
||||
client.on("subgift", (channel, username, streakMonths, recipient, methods, userstate) => {
|
||||
let senderCount = ~~userstate["msg-param-sender-count"];
|
||||
client.say(channel, `/me Hello World!`);
|
||||
});
|
||||
// Anon Gifted Sub Upgraded to Paid
|
||||
// When @someone Randomly Gifts a Sub
|
||||
// --------------------------------
|
||||
client.on("submysterygift", (channel, username, numbOfSubs, methods, userstate) => {
|
||||
let senderCount = ~~userstate["msg-param-sender-count"];
|
||||
client.say(channel, `/me Hello World!`);
|
||||
});
|
||||
// Anon Gifted Sub Upgraded to Paid
|
||||
// When @someone Re-Subs
|
||||
// --------------------------------
|
||||
client.on("resub", function (channel, username, months, message, userstate, methods) {
|
||||
client.say(channel, `/me Hello World!`);
|
||||
});
|
||||
// Anon Gifted Sub Upgraded to Paid
|
||||
// When @someone Subs for the first time!
|
||||
// --------------------------------
|
||||
client.on("subscription", function (channel, username, method, message, userstate) {
|
||||
client.say(channel, `/me Hello World!`);
|
||||
});
|
||||
// Anon Gifted Sub Upgraded to Paid
|
||||
// When a DM/Whisper is recieved on the bot account
|
||||
// --------------------------------
|
||||
client.on("whisper", (from, userstate, message, self) => {
|
||||
// Don't listen to my own messages..
|
||||
if (self) return;
|
||||
client.say(channel, `/me Hello World!`);
|
||||
});
|
||||
|
||||
|
||||
// ! COMMAND => command
|
||||
// ================================
|
||||
client.on('message', (channel, tags, message, self) => {
|
||||
if(self || !message.startsWith('!')) return;
|
||||
|
||||
const args = message.slice(1).split(' ');
|
||||
const command = args.shift().toLowerCase();
|
||||
const botUserState = client.userstate[channel];
|
||||
const amMod = botUserState !== undefined && botUserState.mod === true;
|
||||
if(isModUp) {
|
||||
// ! MOD Commands
|
||||
// ================================
|
||||
if(isModUp) {
|
||||
else if(command === 'abc' || command === 'alpha') {
|
||||
client.say(channel, `Mod Command: A`);
|
||||
}
|
||||
|
@ -153,7 +152,6 @@ client.on('message', (channel, tags, message, self) => {
|
|||
else if(command === 'heyo' || command === 'helloworld') {
|
||||
client.say(channel, `${tags.username} says hi to @${args.join(' ')}!`);
|
||||
}
|
||||
|
||||
// ERROR RESPONSE
|
||||
// --------------------------------
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue