more obs control

This commit is contained in:
Chris Ham
2018-09-12 07:43:10 -07:00
parent 3e1874ce4d
commit bd93260e21
15 changed files with 55 additions and 34 deletions

View File

@@ -15,7 +15,11 @@
"channels": ["#greenham"],
"cmdPrefix": "$",
"blacklistedUsers": [],
"admins": ["greenham","greenhambot"]
"admins": ["greenham","greenhambot"],
"editorLogin": {
"username": "greenham",
"oauth": "oauth:gmi4sjl3k0we0d4gsppkrcqcjpdma6"
}
},
"obs": {
"websocket": {

BIN
sfx/bananas.mp3 Executable file

Binary file not shown.

BIN
sfx/dbio.mp3 Executable file

Binary file not shown.

BIN
sfx/highscore.mp3 Executable file

Binary file not shown.

BIN
sfx/lanmo.mp3 Executable file

Binary file not shown.

BIN
sfx/loz.mp3 Executable file

Binary file not shown.

BIN
sfx/mash.mp3 Executable file

Binary file not shown.

BIN
sfx/mmmm.mp3 Executable file

Binary file not shown.

BIN
sfx/onejoint.mp3 Executable file

Binary file not shown.

BIN
sfx/robotears.mp3 Executable file

Binary file not shown.

BIN
sfx/toofat.mp3 Executable file

Binary file not shown.

BIN
sfx/trinexx.mp3 Executable file

Binary file not shown.

BIN
sfx/vitty.mp3 Executable file

Binary file not shown.

BIN
sfx/youguys.mp3 Executable file

Binary file not shown.

View File

@@ -2,6 +2,10 @@
* GHBot4Twitch
*/
// @TODO: Make the bot aware of what video is current active
// @TODO: Change video playlist source on an interval
// Import modules
const irc = require('irc');
const OBSWebSocket = require('obs-websocket-js');
@@ -19,8 +23,8 @@ const init = (config) => {
obs.connect({ address: config.obs.websocket.address, password: config.obs.websocket.password })
.then(() => {
console.log(`Success! We're connected to OBS!`);
obs.getSourcesList().then(data => {console.log(data.sources)}).catch(console.error);
twitchChat = twitchInit(config, obs);
//obs.getSourcesList().then(data => {console.log(data.sources)}).catch(console.error);
twitchInit(config, obs);
})
.catch(err => {
console.log(err);
@@ -33,7 +37,7 @@ const init = (config) => {
const twitchInit = (config, obs) => {
console.log('Connecting to Twitch...');
// Connect to Twitch IRC server
// Connect to Twitch IRC server with the Bot
let twitchChat = new irc.Client(config.twitch.ircServer, config.twitch.username, {
password: config.twitch.oauth,
autoRejoin: true,
@@ -42,6 +46,15 @@ const init = (config) => {
debug: config.debug
});
// Also connect with an editor account
let editorChat = new irc.Client(config.twitch.ircServer, config.twitch.editorLogin.username, {
password: config.twitch.editorLogin.oauth,
autoRejoin: true,
retryCount: 10,
channels: config.twitch.channels,
debug: config.debug
});
// Set up event listeners for Twitch
twitchChat.addListener('message', (from, to, message) => {
// Ignore everything from blacklisted users
@@ -54,42 +67,32 @@ const init = (config) => {
// Listen for specific commands from admins
if (config.twitch.admins.includes(from) || from === config.twitch.username.toLowerCase()) {
if (commandNoPrefix === 'show') {
if (commandNoPrefix === 'show' || commandNoPrefix === 'hide') {
let newVisibility = (commandNoPrefix === 'show');
let visibleTerm = (newVisibility ? 'visible' : 'hidden');
let target = commandParts[1] || false;
if (!target) {
twitchChat.say(to, `A scene item name is required!`);
return;
}
obs.getSceneItemProperties({"item": target})
.then(data => {
if (data.visible === true) {
twitchChat.say(to, "This scene item is already visible. DerpHam");
} else {
obs.setSceneItemProperties({"item": target, "visible": true})
.then(res => {
twitchChat.say(to, `${target} is now visible.`);
})
.catch(console.error);
}
})
.catch(err => {
twitchChat.say(to, JSON.stringify(err));
});
} else if (commandNoPrefix === 'hide') {
let target = commandParts[1] || false;
if (!target) {
twitchChat.say(to, `A scene item name is required!`);
return;
let sceneItem = {"item": target};
let sceneOrGroup = commandParts[2] || false;
if (sceneOrGroup !== false) {
sceneItem["scene-name"] = sceneOrGroup;
}
obs.getSceneItemProperties({"item": target})
obs.getSceneItemProperties(sceneItem)
.then(data => {
if (data.visible === false) {
twitchChat.say(to, "This scene item is already hidden. DerpHam");
if (data.visible === newVisibility) {
twitchChat.say(to, `This scene item is already ${visibleTerm}. DerpHam`);
} else {
obs.setSceneItemProperties({"item": target, "visible": false})
sceneItem.visible = newVisibility;
obs.setSceneItemProperties(sceneItem)
.then(res => {
twitchChat.say(to, `${target} is now hidden.`);
twitchChat.say(to, `${target} is now ${visibleTerm}.`);
})
.catch(console.error);
}
@@ -98,15 +101,26 @@ const init = (config) => {
twitchChat.say(to, JSON.stringify(err));
});
} else if (commandNoPrefix === 'auw') {
// @TODO: pause songrequest or otherwise fade out its audio
obs.setSceneItemProperties({"item": "everybody-wow", "visible": true})
.then(res => {
// fade out headphone audio
/*for (i = 100; i >= 0; i--) {
obs.setVolume({"source": "headphones", "volume": i/100});
}*/
// @TODO: send command to mute the songrequest audio
editorChat.say(to, '!volume 0');
twitchChat.say(to, 'Everybody OwenWow');
// hide the source after a certain amount of time (248s in this case)
setTimeout(() => {
obs.setSceneItemProperties({"item": "everybody-wow", "visible": false})
.then(res => {
// @TODO: resume songrequest or otherwise fade in its audio
// fade in headphone audio
/*for (i = 1; i <= 100; i++) {
obs.setVolume({"source": "headphones", "volume": i/100});
}*/
// @TODO: send command to unmute the songrequest audio
editorChat.say(to, '!volume 75');
twitchChat.say(to, 'OwenWow');
}).catch(console.error);
}, 248000);
@@ -143,6 +157,11 @@ const init = (config) => {
console.error('error from Twitch IRC Server: ', message);
}
});
editorChat.addListener('error', message => {
if (message.command != 'err_unknowncommand') {
console.error('error from Twitch IRC Server: ', message);
}
});
twitchChat.addListener('registered', message => {
console.log(`Connected to ${message.server}`);
@@ -163,8 +182,6 @@ const init = (config) => {
twitchChat.addListener('motd', motd => {
console.log(`Received MOTD: ${motd}`);
});
return twitchChat;
}
}