phantombot-plugins/twitch/customOverlay.js

50 lines
1.8 KiB
JavaScript
Raw Normal View History

2022-02-06 19:14:55 +01:00
(function() {
function sendData(tpe, data) {
$.panelsocketserver.sendJSONToAll(JSON.stringify({
'eventFamily': 'overlay',
'eventType': tpe,
'data': data
}));
}
2022-02-06 21:02:09 +01:00
// $.inidb.get('streamInfo', 'lastSub', subscriber);
// $.inidb.get('streamInfo', 'lastFollow', follower);
// $.inidb.get('streamInfo', 'lastDonator', donationUsername);
2022-02-06 19:14:55 +01:00
$.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() {
2022-02-06 19:59:23 +01:00
$.registerChatCommand('./custom/custom/customOverlay.js', 'overlay');
2022-02-06 19:14:55 +01:00
$.registerChatSubcommand('overlay', 'follow', 2);
$.registerChatSubcommand('overlay', 'subscribe', 2);
$.registerChatSubcommand('overlay', 'donation', 2);
$.registerChatSubcommand('overlay', 'timer', 2);
});
})();