This commit is contained in:
2022-02-24 02:05:33 +01:00
parent 7485215ef6
commit 745b6685ea
14 changed files with 306 additions and 1820 deletions

View File

@@ -1,26 +0,0 @@
import PIL.Image, PIL.ImageDraw, PIL.ImageFont
import os
import sys
font = PIL.ImageFont.truetype(os.path.join(os.path.dirname(__file__), './customAlertsMedia/ibmplex.ttf'), 20)
nFrames = 60
width = 500
height = 500
if __name__ == "__main__":
tpe = sys.argv[1]
username = sys.argv[2]
description = sys.argv[3]
target = sys.argv[4]
animated_gif = Image.open("./customAlertsMedia/"+tpe+".gif")
frames = []
for frame in ImageSequence.Iterator(animated_gif):
frame = frame.convert('RGB')
d = PIL.ImageDraw.Draw(frame)
d.text((0, 0), description, font=font, fill=(255, 255, 255))
d.text((0, 100), username, font=font, fill=(255, 255, 255))
frames.append(frame)
frames[0].save(target+tpe+".gif", save_all=True, append_images=frames[1:], duration=100, loop=0, optimize=0, comment="")
os.popen('cp ./customAlertsMedia/'+tpe+'.mp3 '+target+tpe+'.mp3')

View File

@@ -1,47 +1,92 @@
(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");
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('twitchSubscriber', function(event) {
var subscriber = event.getSubscriber();
alert(subscriber.toUpperCase(), "NEW SUBSCRIBER", "subscribe");
});
$.bind('twitchReSubscriber', function(event) {
sendData('subscribe', {
'user': event.getReSubscriber(),
'isReSub': true,
'months': event.getMonths(),
'tier': event.getPlan() / 1000,
'message': event.getMessage()
});
});
$.bind('twitchSubscriptionGift', function(event) {
sendData('gift', {
'recipient': event.getRecipient(),
'user': event.getUsername(),
'months': event.getMonths(),
'isReSub': (parseInt(event.getMonths()) > 1),
'tier': event.getPlan() / 1000
});
$.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);
$.bind('twitchMassSubscriptionGifted', function(event) {
sendData('mgift', {
'user': event.getUsername(),
'amount': event.getAmount(),
'tier': event.getPlan() / 1000
});
})();
});
$.bind('twitchRaid', function(event) {
sendData('raid',{
'user': event.getUsername(),
'viewers': event.getViewers(),
});
});
$.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);
});
})();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 399 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 547 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB