Tweaks and fixes
This commit is contained in:
parent
a8f79d06a6
commit
9c5ec6f9d5
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,4 +1,5 @@
|
||||||
.env
|
.env
|
||||||
twitch.config
|
twitch.config
|
||||||
|
buttsbot.config
|
||||||
|
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
|
||||||
21
bot.js
21
bot.js
|
|
@ -20,8 +20,6 @@ let defaultConfig = {
|
||||||
ignoredUsers: []
|
ignoredUsers: []
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(`* Startup: Loaded config: ${config}`);
|
|
||||||
|
|
||||||
// Client
|
// Client
|
||||||
client.on('message', onMessageHandler);
|
client.on('message', onMessageHandler);
|
||||||
client.on('connected', onConnectedHandler);
|
client.on('connected', onConnectedHandler);
|
||||||
|
|
@ -44,32 +42,37 @@ function isNumeric(n) {
|
||||||
// Event handlers
|
// Event handlers
|
||||||
function onMessageHandler (channel, userstate, message, self) {
|
function onMessageHandler (channel, userstate, message, self) {
|
||||||
var message = message.trim();
|
var message = message.trim();
|
||||||
var messageChannel = userstate['username'];
|
var messageChannel = "#" + userstate['username'];
|
||||||
|
|
||||||
if (channel === "#butt5b0t") {
|
if (channel === "#butt5b0t") {
|
||||||
if (message === "!subscribe") {
|
if (message === "!subscribe") {
|
||||||
client.join("#" + messageChannel);
|
client.join(messageChannel);
|
||||||
client.say(channel, "Joined channel " + messageChannel);
|
client.say(channel, "Joined channel " + messageChannel);
|
||||||
|
|
||||||
if (!opts.channels.includes(messageChannel)) {
|
if (!opts.channels.includes(messageChannel)) {
|
||||||
opts.channels.push(messageChannel);
|
opts.channels.push(messageChannel);
|
||||||
fs.writeFileSync('twitch.config', opts);
|
fs.writeFileSync('twitch.config', JSON.stringify(opts));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(messageChannel in configurations)) {
|
if (!(messageChannel in configurations)) {
|
||||||
configurations[messageChannel] = defaultConfig;
|
configurations[messageChannel] = defaultConfig;
|
||||||
fs.writeFileSync('buttsbot.config');
|
fs.writeFileSync('buttsbot.config', JSON.stringify(configurations));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message === "!unsubscribe") {
|
if (message === "!unsubscribe") {
|
||||||
client.part("#" + messageChannel);
|
client.part(messageChannel);
|
||||||
client.say(channel, "Left channel " + messageChannel);
|
client.say(channel, "Left channel " + messageChannel);
|
||||||
|
|
||||||
if (opts.channels.includes(messageChannel)) {
|
if (opts.channels.includes(messageChannel)) {
|
||||||
var indexChannel = opts.channels.indexOf(messageChannel);
|
var indexChannel = opts.channels.indexOf(messageChannel);
|
||||||
opts.splice(indexChannel, 1);
|
opts.channels.splice(indexChannel, 1);
|
||||||
fs.writeFileSync('twitch.config', opts);
|
fs.writeFileSync('twitch.config', JSON.stringify(opts));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (messageChannel in configurations) {
|
||||||
|
delete configurations[messageChannel];
|
||||||
|
fs.writeFileSync('buttsbot.config', JSON.stringify(configurations));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
{
|
{"#drmcmarco":{"word":"butt","chance":20,"limit":10,"ignoredUsers":[]}}
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user