new sfx and some obs integration

This commit is contained in:
Chris Ham
2018-09-10 21:02:25 -07:00
parent 4ad54f427b
commit 3e1874ce4d
20 changed files with 378 additions and 74 deletions

View File

@@ -7,5 +7,21 @@
"allowedSfxChannels": "bot|alttp-alerts",
"sfxVolume": 0.3,
"botChannel": "bot",
"textCmdCooldown": 5
"textCmdCooldown": 5,
"twitch": {
"ircServer" : "irc.chat.twitch.tv",
"username": "greenhambot",
"oauth": "oauth:90aunml4vwyt7zgulm7s5m7xt4hnpc",
"channels": ["#greenham"],
"cmdPrefix": "$",
"blacklistedUsers": [],
"admins": ["greenham","greenhambot"]
},
"obs": {
"websocket": {
"address": "192.168.0.111:4444",
"password": "goodnewseveryone"
}
},
"debug": false
}

258
package-lock.json generated
View File

@@ -9,10 +9,10 @@
"resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
"integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=",
"requires": {
"co": "^4.6.0",
"fast-deep-equal": "^1.0.0",
"fast-json-stable-stringify": "^2.0.0",
"json-schema-traverse": "^0.3.0"
"co": "4.6.0",
"fast-deep-equal": "1.1.0",
"fast-json-stable-stringify": "2.0.0",
"json-schema-traverse": "0.3.1"
}
},
"asn1": {
@@ -20,7 +20,7 @@
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
"integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==",
"requires": {
"safer-buffer": "~2.1.0"
"safer-buffer": "2.1.2"
}
},
"assert-plus": {
@@ -48,13 +48,39 @@
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz",
"integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ=="
},
"babel-polyfill": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-polyfill/-/babel-polyfill-6.26.0.tgz",
"integrity": "sha1-N5k3q8Z9eJWXCtxiHyhM2WbPIVM=",
"requires": {
"babel-runtime": "6.26.0",
"core-js": "2.5.7",
"regenerator-runtime": "0.10.5"
}
},
"babel-runtime": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
"integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=",
"requires": {
"core-js": "2.5.7",
"regenerator-runtime": "0.11.1"
},
"dependencies": {
"regenerator-runtime": {
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
"integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg=="
}
}
},
"bcrypt-pbkdf": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
"integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=",
"optional": true,
"requires": {
"tweetnacl": "^0.14.3"
"tweetnacl": "0.14.5"
}
},
"bindings": {
@@ -82,6 +108,11 @@
"resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz",
"integrity": "sha1-FXFS/R56bI2YpbcVzzdt+SgARWM="
},
"core-js": {
"version": "2.5.7",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.7.tgz",
"integrity": "sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw=="
},
"core-util-is": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
@@ -97,7 +128,7 @@
"resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
"integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=",
"requires": {
"assert-plus": "^1.0.0"
"assert-plus": "1.0.0"
}
},
"debug": {
@@ -118,11 +149,11 @@
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-11.4.2.tgz",
"integrity": "sha512-MDwpu0lMFTjqomijDl1Ed9miMQe6kB4ifKdP28QZllmLv/HVOJXhatRgjS8urp/wBlOfx+qAYSXcdI5cKGYsfg==",
"requires": {
"long": "^4.0.0",
"prism-media": "^0.0.3",
"snekfetch": "^3.6.4",
"tweetnacl": "^1.0.0",
"ws": "^4.0.0"
"long": "4.0.0",
"prism-media": "0.0.3",
"snekfetch": "3.6.4",
"tweetnacl": "1.0.0",
"ws": "4.1.0"
},
"dependencies": {
"tweetnacl": {
@@ -138,8 +169,8 @@
"integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=",
"optional": true,
"requires": {
"jsbn": "~0.1.0",
"safer-buffer": "^2.1.0"
"jsbn": "0.1.1",
"safer-buffer": "2.1.2"
}
},
"extsprintf": {
@@ -172,7 +203,7 @@
"resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
"integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
"requires": {
"assert-plus": "^1.0.0"
"assert-plus": "1.0.0"
}
},
"har-schema": {
@@ -185,8 +216,8 @@
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.0.tgz",
"integrity": "sha512-+qnmNjI4OfH2ipQ9VQOw23bBd/ibtfbVdK2fYbY4acTDqKTW/YDp9McimZdDbG8iV9fZizUqQMD5xvriB146TA==",
"requires": {
"ajv": "^5.3.0",
"har-schema": "^2.0.0"
"ajv": "5.5.2",
"har-schema": "2.0.0"
}
},
"http-signature": {
@@ -194,11 +225,40 @@
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
"integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=",
"requires": {
"assert-plus": "^1.0.0",
"jsprim": "^1.2.2",
"sshpk": "^1.7.0"
"assert-plus": "1.0.0",
"jsprim": "1.4.1",
"sshpk": "1.14.2"
}
},
"iconv": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/iconv/-/iconv-2.2.3.tgz",
"integrity": "sha1-4ITWDut9c9p/CpwJbkyKvgkL+u0=",
"optional": true,
"requires": {
"nan": "2.10.0"
}
},
"inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"irc": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/irc/-/irc-0.5.2.tgz",
"integrity": "sha1-NxT0doNlqW0LL3dryRFmvrJGS7w=",
"requires": {
"iconv": "2.2.3",
"irc-colors": "1.4.3",
"node-icu-charset-detector": "0.2.0"
}
},
"irc-colors": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/irc-colors/-/irc-colors-1.4.3.tgz",
"integrity": "sha512-VeAnFC9fkb4nB/s6UtTNf3BH2wOk/sSBSzIzCpFwrgoFxVl6J5sov7FXXA0kmbk/mVAZQXfXAsQFjWnGPf4cRg=="
},
"is-buffer": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
@@ -256,9 +316,9 @@
"resolved": "https://registry.npmjs.org/md5/-/md5-2.2.1.tgz",
"integrity": "sha1-U6s41f48iJG6RlMp6iP6wFQBJvk=",
"requires": {
"charenc": "~0.0.1",
"crypt": "~0.0.1",
"is-buffer": "~1.1.1"
"charenc": "0.0.2",
"crypt": "0.0.2",
"is-buffer": "1.1.6"
}
},
"memcache": {
@@ -281,15 +341,24 @@
"resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz",
"integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA=="
},
"node-icu-charset-detector": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/node-icu-charset-detector/-/node-icu-charset-detector-0.2.0.tgz",
"integrity": "sha1-wjINo3Tdy2cfxUy0oOBB4Vb/1jk=",
"optional": true,
"requires": {
"nan": "2.10.0"
}
},
"node-opus": {
"version": "0.2.9",
"resolved": "https://registry.npmjs.org/node-opus/-/node-opus-0.2.9.tgz",
"integrity": "sha512-+IIOdav5D7vHsuLDNk55t17kK2s6c1w4DbfKw8UQxZ635n+AO/SqDE3RpuO3PZKqpWjPtL/chzYZNVxz8/4TUQ==",
"requires": {
"bindings": "~1.2.1",
"commander": "^2.9.0",
"nan": "^2.10.0",
"ogg-packet": "^1.0.0"
"bindings": "1.2.1",
"commander": "2.11.0",
"nan": "2.10.0",
"ogg-packet": "1.0.0"
}
},
"oauth-sign": {
@@ -297,13 +366,42 @@
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
"integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ=="
},
"obs-websocket-js": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/obs-websocket-js/-/obs-websocket-js-1.2.0.tgz",
"integrity": "sha1-aE/Br0r+JlV4wXd2dqW7LKKrwGw=",
"requires": {
"babel-polyfill": "6.26.0",
"debug": "3.1.0",
"sha.js": "2.4.11",
"ws": "5.2.2"
},
"dependencies": {
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
},
"ws": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz",
"integrity": "sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==",
"requires": {
"async-limiter": "1.0.0"
}
}
}
},
"ogg-packet": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/ogg-packet/-/ogg-packet-1.0.0.tgz",
"integrity": "sha1-RbiFchrI991c8iOR1CEGrlM6xng=",
"optional": true,
"requires": {
"ref-struct": "*"
"ref-struct": "1.1.0"
}
},
"performance-now": {
@@ -332,9 +430,9 @@
"integrity": "sha512-2cBCniTtxcGUjDpvFfVpw323a83/0RLSGJJY5l5lcomZWhYpU2cuLdsvYqMixvsdLJ9+sTdzEkju8J8ZHDM2nA==",
"optional": true,
"requires": {
"bindings": "1",
"debug": "2",
"nan": "2"
"bindings": "1.2.1",
"debug": "2.6.9",
"nan": "2.10.0"
}
},
"ref-struct": {
@@ -343,35 +441,40 @@
"integrity": "sha1-XV7mWtQc78Olxf60BYcmHkee3BM=",
"optional": true,
"requires": {
"debug": "2",
"ref": "1"
"debug": "2.6.9",
"ref": "1.3.5"
}
},
"regenerator-runtime": {
"version": "0.10.5",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz",
"integrity": "sha1-M2w+/BIgrc7dosn6tntaeVWjNlg="
},
"request": {
"version": "2.88.0",
"resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz",
"integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==",
"requires": {
"aws-sign2": "~0.7.0",
"aws4": "^1.8.0",
"caseless": "~0.12.0",
"combined-stream": "~1.0.6",
"extend": "~3.0.2",
"forever-agent": "~0.6.1",
"form-data": "~2.3.2",
"har-validator": "~5.1.0",
"http-signature": "~1.2.0",
"is-typedarray": "~1.0.0",
"isstream": "~0.1.2",
"json-stringify-safe": "~5.0.1",
"mime-types": "~2.1.19",
"oauth-sign": "~0.9.0",
"performance-now": "^2.1.0",
"qs": "~6.5.2",
"safe-buffer": "^5.1.2",
"tough-cookie": "~2.4.3",
"tunnel-agent": "^0.6.0",
"uuid": "^3.3.2"
"aws-sign2": "0.7.0",
"aws4": "1.8.0",
"caseless": "0.12.0",
"combined-stream": "1.0.6",
"extend": "3.0.2",
"forever-agent": "0.6.1",
"form-data": "2.3.2",
"har-validator": "5.1.0",
"http-signature": "1.2.0",
"is-typedarray": "1.0.0",
"isstream": "0.1.2",
"json-stringify-safe": "5.0.1",
"mime-types": "2.1.19",
"oauth-sign": "0.9.0",
"performance-now": "2.1.0",
"qs": "6.5.2",
"safe-buffer": "5.1.2",
"tough-cookie": "2.4.3",
"tunnel-agent": "0.6.0",
"uuid": "3.3.2"
},
"dependencies": {
"combined-stream": {
@@ -379,7 +482,7 @@
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
"integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
"requires": {
"delayed-stream": "~1.0.0"
"delayed-stream": "1.0.0"
}
},
"extend": {
@@ -392,9 +495,9 @@
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz",
"integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=",
"requires": {
"asynckit": "^0.4.0",
"asynckit": "0.4.0",
"combined-stream": "1.0.6",
"mime-types": "^2.1.12"
"mime-types": "2.1.19"
}
},
"mime-db": {
@@ -407,7 +510,7 @@
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.19.tgz",
"integrity": "sha512-P1tKYHVSZ6uFo26mtnve4HQFE3koh1UWVkp8YUC+ESBHe945xWSoXuHHiGarDqcEZ+whpCDnlNw5LON0kLo+sw==",
"requires": {
"mime-db": "~1.35.0"
"mime-db": "1.35.0"
}
},
"qs": {
@@ -427,6 +530,15 @@
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"sha.js": {
"version": "2.4.11",
"resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
"integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
"requires": {
"inherits": "2.0.3",
"safe-buffer": "5.1.2"
}
},
"snekfetch": {
"version": "3.6.4",
"resolved": "https://registry.npmjs.org/snekfetch/-/snekfetch-3.6.4.tgz",
@@ -437,15 +549,15 @@
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.2.tgz",
"integrity": "sha1-xvxhZIo9nE52T9P8306hBeSSupg=",
"requires": {
"asn1": "~0.2.3",
"assert-plus": "^1.0.0",
"bcrypt-pbkdf": "^1.0.0",
"dashdash": "^1.12.0",
"ecc-jsbn": "~0.1.1",
"getpass": "^0.1.1",
"jsbn": "~0.1.0",
"safer-buffer": "^2.0.2",
"tweetnacl": "~0.14.0"
"asn1": "0.2.4",
"assert-plus": "1.0.0",
"bcrypt-pbkdf": "1.0.2",
"dashdash": "1.14.1",
"ecc-jsbn": "0.1.2",
"getpass": "0.1.7",
"jsbn": "0.1.1",
"safer-buffer": "2.1.2",
"tweetnacl": "0.14.5"
}
},
"tough-cookie": {
@@ -453,8 +565,8 @@
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz",
"integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==",
"requires": {
"psl": "^1.1.24",
"punycode": "^1.4.1"
"psl": "1.1.29",
"punycode": "1.4.1"
}
},
"tunnel-agent": {
@@ -462,7 +574,7 @@
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
"integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
"requires": {
"safe-buffer": "^5.0.1"
"safe-buffer": "5.1.2"
}
},
"tweetnacl": {
@@ -481,9 +593,9 @@
"resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
"integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=",
"requires": {
"assert-plus": "^1.0.0",
"assert-plus": "1.0.0",
"core-util-is": "1.0.2",
"extsprintf": "^1.2.0"
"extsprintf": "1.3.0"
}
},
"ws": {
@@ -491,8 +603,8 @@
"resolved": "https://registry.npmjs.org/ws/-/ws-4.1.0.tgz",
"integrity": "sha512-ZGh/8kF9rrRNffkLFV4AzhvooEclrOH0xaugmqGsIfFgOE/pIz4fMc4Ef+5HSQqTEug2S9JZIWDR47duDSLfaA==",
"requires": {
"async-limiter": "~1.0.0",
"safe-buffer": "~5.1.0"
"async-limiter": "1.0.0",
"safe-buffer": "5.1.2"
},
"dependencies": {
"safe-buffer": {

View File

@@ -6,10 +6,12 @@
"dependencies": {
"discord.js": "^11.4.2",
"ffmpeg-binaries": "^3.2.2",
"irc": "^0.5.2",
"md5": "^2.2.1",
"memcache": "^0.3.0",
"moment": "^2.22.2",
"node-opus": "^0.2.9",
"obs-websocket-js": "^1.2.0",
"request": "^2.88.0"
},
"devDependencies": {},

BIN
sfx/arise.mp3 Executable file

Binary file not shown.

BIN
sfx/auhwuh.mp3 Executable file

Binary file not shown.

BIN
sfx/carlcandy.mp3 Executable file

Binary file not shown.

BIN
sfx/disagree.mp3 Executable file

Binary file not shown.

BIN
sfx/dontmatter.mp3 Executable file

Binary file not shown.

BIN
sfx/gross.mp3 Executable file

Binary file not shown.

BIN
sfx/hahaa.mp3 Executable file

Binary file not shown.

BIN
sfx/hightonight.mp3 Executable file

Binary file not shown.

BIN
sfx/idc.mp3 Executable file

Binary file not shown.

BIN
sfx/kudos.mp3 Executable file

Binary file not shown.

BIN
sfx/lang.mp3 Executable file

Binary file not shown.

BIN
sfx/onfire.mp3 Executable file

Binary file not shown.

BIN
sfx/popup.mp3 Executable file

Binary file not shown.

BIN
sfx/rockin.mp3 Executable file

Binary file not shown.

BIN
sfx/threat.mp3 Executable file

Binary file not shown.

BIN
sfx/tonight.mp3 Executable file

Binary file not shown.

174
twitch.js Executable file
View File

@@ -0,0 +1,174 @@
/**
* GHBot4Twitch
*/
// Import modules
const irc = require('irc');
const OBSWebSocket = require('obs-websocket-js');
// Read internal configuration
let config = require('./config.json');
let twitchChat;
const init = (config) => {
let botChannel = '#' + config.twitch.username.toLowerCase();
// Connect to OBS Websocket
const obs = new OBSWebSocket();
console.log(`Connecting to OBS...`);
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);
})
.catch(err => {
console.log(err);
});
obs.on('error', err => {
console.error('OBS socket error:', err);
});
const twitchInit = (config, obs) => {
console.log('Connecting to Twitch...');
// Connect to Twitch IRC server
let twitchChat = new irc.Client(config.twitch.ircServer, config.twitch.username, {
password: config.twitch.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
if (config.twitch.blacklistedUsers.includes(from)) return;
// Listen for commands that start with the designated prefix
if (message.startsWith(config.twitch.cmdPrefix)) {
let commandParts = message.slice(config.twitch.cmdPrefix.length).split(' ');
let commandNoPrefix = commandParts[0] || '';
// Listen for specific commands from admins
if (config.twitch.admins.includes(from) || from === config.twitch.username.toLowerCase()) {
if (commandNoPrefix === 'show') {
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;
}
obs.getSceneItemProperties({"item": target})
.then(data => {
if (data.visible === false) {
twitchChat.say(to, "This scene item is already hidden. DerpHam");
} else {
obs.setSceneItemProperties({"item": target, "visible": false})
.then(res => {
twitchChat.say(to, `${target} is now hidden.`);
})
.catch(console.error);
}
})
.catch(err => {
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 => {
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
twitchChat.say(to, 'OwenWow');
}).catch(console.error);
}, 248000);
}).catch(console.error);
} else if (commandNoPrefix === 'switch') {
let target = commandParts[1] || false;
if (!target) {
twitchChat.say(to, `A scene name is required!`);
return;
}
obs.getCurrentScene()
.then(data => {
if (data.name === target) {
twitchChat.say(to, `That scene is already active! DerpHam`);
} else {
obs.setCurrentScene({"scene-name": target})
.then(() => {twitchChat.say(to, `${target} is now active`)})
.catch(console.error);
}
})
.catch(console.error);
} else if (commandNoPrefix === 'reboot') {
console.log('Received request from admin to reboot...');
twitchChat.say(to, 'Rebooting...');
process.exit(0);
}
}
}
});
twitchChat.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}`);
});
twitchChat.addListener('join', (channel, nick, message) => {
if (nick === config.twitch.username) {
console.log(`Joined channel ${channel}`);
}
});
twitchChat.addListener('part', (channel, nick, message) => {
if (nick === config.twitch.username) {
console.log(`Left channel ${channel}`);
}
});
twitchChat.addListener('motd', motd => {
console.log(`Received MOTD: ${motd}`);
});
return twitchChat;
}
}
init(config);
// catches Promise errors
process.on('unhandledRejection', console.error);