diff --git a/config.json b/config.json index 060e022..e3da6fe 100755 --- a/config.json +++ b/config.json @@ -15,7 +15,11 @@ "channels": ["#greenham"], "cmdPrefix": "$", "blacklistedUsers": [], - "admins": ["greenham","greenhambot"] + "admins": ["greenham","greenhambot"], + "editorLogin": { + "username": "greenham", + "oauth": "oauth:gmi4sjl3k0we0d4gsppkrcqcjpdma6" + } }, "obs": { "websocket": { diff --git a/sfx/bananas.mp3 b/sfx/bananas.mp3 new file mode 100755 index 0000000..7fe5736 Binary files /dev/null and b/sfx/bananas.mp3 differ diff --git a/sfx/dbio.mp3 b/sfx/dbio.mp3 new file mode 100755 index 0000000..b4796de Binary files /dev/null and b/sfx/dbio.mp3 differ diff --git a/sfx/highscore.mp3 b/sfx/highscore.mp3 new file mode 100755 index 0000000..6592131 Binary files /dev/null and b/sfx/highscore.mp3 differ diff --git a/sfx/lanmo.mp3 b/sfx/lanmo.mp3 new file mode 100755 index 0000000..068da91 Binary files /dev/null and b/sfx/lanmo.mp3 differ diff --git a/sfx/loz.mp3 b/sfx/loz.mp3 new file mode 100755 index 0000000..f230f08 Binary files /dev/null and b/sfx/loz.mp3 differ diff --git a/sfx/mash.mp3 b/sfx/mash.mp3 new file mode 100755 index 0000000..6f9ec69 Binary files /dev/null and b/sfx/mash.mp3 differ diff --git a/sfx/mmmm.mp3 b/sfx/mmmm.mp3 new file mode 100755 index 0000000..30871a9 Binary files /dev/null and b/sfx/mmmm.mp3 differ diff --git a/sfx/onejoint.mp3 b/sfx/onejoint.mp3 new file mode 100755 index 0000000..10f236f Binary files /dev/null and b/sfx/onejoint.mp3 differ diff --git a/sfx/robotears.mp3 b/sfx/robotears.mp3 new file mode 100755 index 0000000..9c7a7a3 Binary files /dev/null and b/sfx/robotears.mp3 differ diff --git a/sfx/toofat.mp3 b/sfx/toofat.mp3 new file mode 100755 index 0000000..7a2ae7c Binary files /dev/null and b/sfx/toofat.mp3 differ diff --git a/sfx/trinexx.mp3 b/sfx/trinexx.mp3 new file mode 100755 index 0000000..b685baf Binary files /dev/null and b/sfx/trinexx.mp3 differ diff --git a/sfx/vitty.mp3 b/sfx/vitty.mp3 new file mode 100755 index 0000000..0bb29ec Binary files /dev/null and b/sfx/vitty.mp3 differ diff --git a/sfx/youguys.mp3 b/sfx/youguys.mp3 new file mode 100755 index 0000000..47972e1 Binary files /dev/null and b/sfx/youguys.mp3 differ diff --git a/twitch.js b/twitch.js index f7a4d17..a306f84 100755 --- a/twitch.js +++ b/twitch.js @@ -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; } }