50 lines
1.8 KiB
JavaScript
50 lines
1.8 KiB
JavaScript
(function() {
|
|
|
|
|
|
function sendData(tpe, data) {
|
|
$.panelsocketserver.sendJSONToAll(JSON.stringify({
|
|
'eventFamily': 'overlay',
|
|
'eventType': tpe,
|
|
'data': data
|
|
}));
|
|
}
|
|
|
|
// $.inidb.get('streamInfo', 'lastSub', subscriber);
|
|
// $.inidb.get('streamInfo', 'lastFollow', follower);
|
|
// $.inidb.get('streamInfo', 'lastDonator', donationUsername);
|
|
|
|
$.bind('command', function(event) {
|
|
|
|
const sender = "" + event.getSender().toLowerCase(),
|
|
command = event.getCommand(),
|
|
args = event.getArgs(),
|
|
action = args[0],
|
|
value = args[1];
|
|
|
|
if (command.equalsIgnoreCase('overlay')) {
|
|
if (!action) {
|
|
$.say($.whisperPrefix(sender) + $.lang.get('customOverlay.help', ' Use "!overlay [follow | subscribe | donation | timer] value" to set overlay data.'));
|
|
} else if (action.equalsIgnoreCase('follow')) {
|
|
sendData(action, value);
|
|
} else if (action.equalsIgnoreCase('subscribe')) {
|
|
sendData(action, value);
|
|
} else if (action.equalsIgnoreCase('donation')) {
|
|
sendData(action, value);
|
|
} else if (action.equalsIgnoreCase('timer')) {
|
|
sendData(action, new Date(Date.now().getTime()+value*1000*60));
|
|
} else {
|
|
$.say($.whisperPrefix(sender) + $.lang.get('customOverlay.help'));
|
|
}
|
|
}
|
|
});
|
|
|
|
$.bind('initReady', function() {
|
|
$.registerChatCommand('./custom/custom/customOverlay.js', 'overlay');
|
|
|
|
$.registerChatSubcommand('overlay', 'follow', 2);
|
|
$.registerChatSubcommand('overlay', 'subscribe', 2);
|
|
$.registerChatSubcommand('overlay', 'donation', 2);
|
|
$.registerChatSubcommand('overlay', 'timer', 2);
|
|
});
|
|
|
|
})(); |