2022-02-05 13:00:32 +01:00
|
|
|
(function() {
|
2022-02-23 21:43:59 +01:00
|
|
|
|
2022-02-24 02:05:33 +01:00
|
|
|
function sendData(tpe, d) {
|
|
|
|
$.panelsocketserver.sendJSONToAll(JSON.stringify({
|
|
|
|
'eventFamily': 'calert',
|
|
|
|
'eventType': tpe,
|
|
|
|
'data': d
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
$.bind('twitchFollow', function(event) {
|
|
|
|
sendData('follow',{ 'user': event.getFollower()});
|
|
|
|
});
|
|
|
|
$.bind('twitchSubscriber', function(event) {
|
|
|
|
sendData('subscribe', {
|
|
|
|
'user': event.getSubscriber(),
|
|
|
|
'isReSub': false,
|
|
|
|
'months': 0,
|
|
|
|
'tier': event.getPlan() / 1000,
|
|
|
|
'message': event.getMessage()
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$.bind('twitchReSubscriber', function(event) {
|
|
|
|
sendData('subscribe', {
|
|
|
|
'user': event.getReSubscriber(),
|
|
|
|
'isReSub': true,
|
|
|
|
'months': event.getMonths(),
|
|
|
|
'tier': event.getPlan() / 1000,
|
|
|
|
'message': event.getMessage()
|
2022-02-05 13:00:32 +01:00
|
|
|
});
|
2022-02-24 02:05:33 +01:00
|
|
|
});
|
|
|
|
$.bind('twitchSubscriptionGift', function(event) {
|
|
|
|
sendData('gift', {
|
|
|
|
'recipient': event.getRecipient(),
|
|
|
|
'user': event.getUsername(),
|
|
|
|
'months': event.getMonths(),
|
|
|
|
'isReSub': (parseInt(event.getMonths()) > 1),
|
|
|
|
'tier': event.getPlan() / 1000
|
2022-02-05 13:00:32 +01:00
|
|
|
});
|
2022-02-24 02:05:33 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$.bind('twitchMassSubscriptionGifted', function(event) {
|
|
|
|
sendData('mgift', {
|
|
|
|
'user': event.getUsername(),
|
|
|
|
'amount': event.getAmount(),
|
|
|
|
'tier': event.getPlan() / 1000
|
|
|
|
});
|
|
|
|
});
|
2022-02-06 19:30:05 +01:00
|
|
|
|
2022-02-24 02:05:33 +01:00
|
|
|
$.bind('twitchRaid', function(event) {
|
|
|
|
sendData('raid',{
|
|
|
|
'user': event.getUsername(),
|
|
|
|
'viewers': event.getViewers(),
|
2022-02-06 19:59:23 +01:00
|
|
|
});
|
2022-02-24 02:05:33 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$.bind('twitchBits', function (event) {
|
|
|
|
sendData('bits', {
|
|
|
|
'user': event.getUsername(),
|
|
|
|
'amount': event.getBits(),
|
|
|
|
'message': event.getMessage()
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$.bind('command', function(event) {
|
|
|
|
const sender = "" + event.getSender().toLowerCase(),
|
|
|
|
command = event.getCommand(),
|
|
|
|
args = event.getArgs(),
|
|
|
|
action = args[0];
|
|
|
|
|
|
|
|
if (command.equalsIgnoreCase('calert')) {
|
|
|
|
if (!action) {
|
|
|
|
$.say($.whisperPrefix(sender) + $.lang.get('calert.help', ' Use "!calert [follow | subsribe | donation] user" to trigger alert.'));
|
|
|
|
} else if (action.equalsIgnoreCase('follow')) {
|
|
|
|
alert(args[1].toUpperCase(), "NEW FOLLOWER", "follow");
|
|
|
|
} else if (action.equalsIgnoreCase('subscribe')) {
|
|
|
|
alert(args[1].toUpperCase(), "NEW SUBSCRIBER", "subscribe");
|
|
|
|
} else if (action.equalsIgnoreCase('donation')) {
|
|
|
|
alert(args[1].toUpperCase(), "NEW DONATION", "donation");
|
|
|
|
} else {
|
|
|
|
$.say($.whisperPrefix(sender) + $.lang.get('calert.help', ' Use "!calert [follow | subsribe | donation] user" to trigger alert.'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$.bind('initReady', function() {
|
|
|
|
$.registerChatCommand('./custom/custom/customAlerts.js', 'calert');
|
|
|
|
$.registerChatSubcommand('calert', 'follow', 2);
|
|
|
|
$.registerChatSubcommand('calert', 'subscribe', 2);
|
|
|
|
$.registerChatSubcommand('calert', 'donation', 2);
|
|
|
|
});
|
|
|
|
})();
|