47 lines
1.9 KiB
JavaScript
47 lines
1.9 KiB
JavaScript
(function() {
|
|
function alert(username, desc, tpe) {
|
|
var pb = new java.lang.ProcessBuilder("/usr/bin/python3", "./Main.py", tpe, username, desc, "/opt/PhantomBot/config/gif-alerts/");
|
|
var proc = pb.start();
|
|
proc.waitFor();
|
|
|
|
$.panelsocketserver.alertImage(tpe+".gif?noise=" + Math.floor(Math.random() * 1000 + 1));
|
|
}
|
|
|
|
$.bind('twitchFollow', function(event) {
|
|
var follower = event.getFollower();
|
|
alert(follower.toUpperCase(), "NEW FOLLOWER", "follow");
|
|
});
|
|
$.bind('twitchSubscriber', function(event) {
|
|
var subscriber = event.getSubscriber();
|
|
alert(subscriber.toUpperCase(), "NEW SUBSCRIBER", "subscribe");
|
|
});
|
|
|
|
$.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);
|
|
});
|
|
})();
|
|
|