This commit is contained in:
commit
9983731dd6
57
nmpb-mirror.js
Normal file
57
nmpb-mirror.js
Normal file
@ -0,0 +1,57 @@
|
||||
var nmpb_id = "561738578bfc6a71d8c9a907";
|
||||
var output_channel = "lobby";
|
||||
var input_channel = "NMPB Autoplayer (Troll Heaven2)";
|
||||
var my_name = "NMPB (Ray890)*";
|
||||
var mppUri = "ws://mpp-proxy-mpp-proxy.a3c1.starter-us-west-1.openshiftapps.com:80";
|
||||
|
||||
var Client = require('mpp-client');
|
||||
|
||||
var client1 = new Client(mppUri);
|
||||
client1.setChannel(output_channel);
|
||||
var client2 = new Client(mppUri);
|
||||
client2.setChannel(input_channel);
|
||||
|
||||
function startClients() {
|
||||
client1.start();
|
||||
setTimeout(function(){
|
||||
client2.start();
|
||||
}, 2000);
|
||||
}
|
||||
startClients();
|
||||
|
||||
client1.on("hi", function(){
|
||||
client1.sendArray([{m:'userset', set:{name:my_name}}]);
|
||||
});
|
||||
|
||||
client1.on("disconnect", function(){
|
||||
client1.stop();
|
||||
client2.stop();
|
||||
setTimeout(()=>{
|
||||
startClients();
|
||||
}, 5000);
|
||||
});
|
||||
|
||||
|
||||
// NMPB notes to lobby
|
||||
client2.on('n', msg => {
|
||||
if (client2.findParticipantById(msg.p)._id != nmpb_id) return;
|
||||
client1.sendArray([msg]);
|
||||
});
|
||||
// NMPB chat to lobby
|
||||
client2.on('a', msg => {
|
||||
if (client2.findParticipantById(msg.p)._id != nmpb_id) return;
|
||||
client1.sendArray([{m:'a', message: msg.a}]);
|
||||
});
|
||||
|
||||
// lobby commands to NMPB
|
||||
var NMPB_commands = `
|
||||
help h list search title color info about
|
||||
upload u
|
||||
auto a play stop random r restart rr set pos sustain
|
||||
backwards b mistakes tempo speed inverse mirror octave oct echo transpose tp
|
||||
`.trim().split('\n').join('').split(' ');
|
||||
client1.on('a', msg => {
|
||||
if (!msg.a.startsWith('/')) return;
|
||||
if (!NMPB_commands.includes(msg.a.split(' ')[0].substr(1))) return;
|
||||
client2.sendArray([{m:'a', message: msg.a}]);
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user