This commit is contained in:
choelzl 2022-02-23 19:38:39 +01:00
parent 9012cf1d64
commit 1e96fa1846
Signed by: sora
GPG Key ID: A362EA0491E2EEA0
2 changed files with 57 additions and 40 deletions

View File

@ -1,9 +1,8 @@
(function() { (function() {
function getEmotes(event, message){ function getNoTwitchEmotes(event, message){
var emotes = event.getTags().get('emotes'), var emotes = event.getTags().get('emotes'),
str = message, str = message, i;
i;
if (emotes.length() > 0) { if (emotes.length() > 0) {
emotes = emotes.replaceAll('[0-9]+:', '').split('/'); emotes = emotes.replaceAll('[0-9]+:', '').split('/');
@ -15,59 +14,65 @@
} }
function sendData(tpe, data) { function sendData(tpe, te, ce) {
$.panelsocketserver.sendJSONToAll(JSON.stringify({ $.panelsocketserver.sendJSONToAll(JSON.stringify({
'eventFamily': 'emote', 'eventFamily': 'emote',
'eventType': tpe, 'eventType': tpe,
'data': data 'data': {
twitch: te,
custom: ce,
}
})); }));
} }
$.bind('ircChannelMessage', function(event){ $.bind('ircChannelMessage', function(event){
var sender = event.getSender(), var sender = event.getSender(),
message = event.getMessage().toLowerCase(), message = event.getMessage();
messageLength = message.length(),
tags = event.getTags(); tags = event.getTags();
$.consoleLn(message) if(messsage[0] != '!')
$.consoleLn(tags) sendData('bounce',event.getTags().get('emotes'), getNoTwitchEmotes(event,message))
}) })
$.bind('command', function(event) { $.bind('command', function(event) {
const sender = "" + event.getSender().toLowerCase(), const sender = "" + event.getSender().toLowerCase(),
command = event.getCommand(), command = event.getCommand(),
args = event.getArgs(), args = event.getArgs(),
action = args[0], action = args[0];
value = args[1];
if (command.equalsIgnoreCase('overlay')) { if (command.equalsIgnoreCase('ew')) {
if (!action) { if (!action) {
$.say($.whisperPrefix(sender) + $.lang.get('ew.help', ' Use "!ew [follow | subscribe | donation | timer] value" to set overlay data.')); $.say($.whisperPrefix(sender) + $.lang.get('ew.help', ' Use "!ew [rain | firework | volcano | bomb | explosion] emote" to render emotes.'));
} else if (action.equalsIgnoreCase('follow')) { } else if (action.equalsIgnoreCase('rain')) {
sendData(action, value); sendData('rain',event.getTags().get('emotes'), getNoTwitchEmotes(event,event.messsage))
} else if (action.equalsIgnoreCase('subscribe')) { } else if (action.equalsIgnoreCase('firework')) {
sendData(action, value); sendData('firework',event.getTags().get('emotes'), getNoTwitchEmotes(event,event.messsage))
} else if (action.equalsIgnoreCase('donation')) { } else if (action.equalsIgnoreCase('volcano')) {
sendData(action, value); sendData('volcano',event.getTags().get('emotes'), getNoTwitchEmotes(event,event.messsage))
} else if (action.equalsIgnoreCase('timer')) { } else if (action.equalsIgnoreCase('bomb')) {
sendData(action, new Date(Date.now().getTime()+value*1000*60)); sendData('bomb',event.getTags().get('emotes'), getNoTwitchEmotes(event,event.messsage))
} else if (action.equalsIgnoreCase('explosion')) {
sendData('explosion',event.getTags().get('emotes'), getNoTwitchEmotes(event,event.messsage))
} else { } else {
$.say($.whisperPrefix(sender) + $.lang.get('ew.help')); $.say($.whisperPrefix(sender) + $.lang.get('ew.help', ' Use "!ew [rain | firework | volcano | bomb | explosion] emote" to render emotes.'));
} }
} }
}); });
$.bind('twitchFollow', function(event) { $.bind('twitchFollow', function(event) {
sendData('follow', event.getFollower()); sendData('firework', [],['AYAYA'])
}); });
$.bind('twitchSubscriber', function(event) { $.bind('twitchSubscriber', function(event) {
sendData('subscribe', event.getSubscriber()); sendData('volcano', [], ['AYAYA']);
}); });
$.bind('initReady', function() { $.bind('initReady', function() {
$.registerChatCommand('./custom/custom/customOverlay.js', 'ew'); $.registerChatCommand('./custom/custom/customOverlay.js', 'ew');
$.registerChatSubcommand('ew', 'rain', 2);
$.registerChatSubcommand('ew', 'follow', 2); $.registerChatSubcommand('ew', 'firework', 2);
$.registerChatSubcommand('ew', 'volcano', 2);
$.registerChatSubcommand('ew', 'bomb', 2);
$.registerChatSubcommand('ew', 'explosion', 2);
}); });
})(); })();

View File

@ -220,7 +220,7 @@ $(async function () {
super(emote,data) super(emote,data)
let speed = randRange(5,15); let speed = randRange(5,15);
let fang = 2*Math.PI* (args.angle/360) let fang = 2*Math.PI* (args.angle/360)
let ang = randRange(-fang/2, +fang/2)+Math.PI/2 ;//+ 2*(angle/360)*Math.PI; let ang = randRange(-fang/2, +fang/2)+Math.PI/2;
this.setPhysics(args.x,args.y, this.setPhysics(args.x,args.y,
Math.cos(ang)*speed, Math.cos(ang)*speed,
-Math.sin(ang)*speed, -Math.sin(ang)*speed,
@ -244,7 +244,7 @@ $(async function () {
super.update(tick); super.update(tick);
if(this.y <= canvas.height/4 && this.time < drt){ if(this.y <= canvas.height/4 && this.time < drt){
this.time = drt; this.time = drt;
genExplosion(this.x,this.y,360) genExplosion(this.x,this.y,360, this.sete)
} }
} }
} }
@ -263,7 +263,7 @@ $(async function () {
super.update(tick); super.update(tick);
if(this.y >= canvas.height - this.size && this.time < drt){ if(this.y >= canvas.height - this.size && this.time < drt){
this.time = drt; this.time = drt;
genExplosion(this.x,this.y,60) genExplosion(this.x,this.y,60, this.sete)
} }
} }
} }
@ -275,25 +275,25 @@ $(async function () {
setTimeout(()=>{particles.pop()}, drt*1000+2000); setTimeout(()=>{particles.pop()}, drt*1000+2000);
} }
const genExplosion = (x,y,ang) =>{ const genExplosion = (x,y,ang,em) =>{
for(let i=0; i<100; ++i) createParticule(ExplosionP, randEmote(), {},{x:x,y:y,angle:ang}); for(let i=0; i<100; ++i) createParticule(ExplosionP, em? em:randEmote(), {},{x:x,y:y,angle:ang});
} }
const genRain = () => { const genRain = (em) => {
let xpos = randRange(0, canvas.width); let xpos = randRange(0, canvas.width);
let time = 0; let time = 0;
const interval = setInterval(()=>{ const interval = setInterval(()=>{
for(let i=0; i<10; ++i) createParticule(RainP, randEmote(), {},{}); for(let i=0; i<10; ++i) createParticule(RainP, em? em:randEmote(), {},{});
++time; ++time;
if(time > 50) clearInterval(interval); if(time > 50) clearInterval(interval);
}, 100); }, 100);
} }
const genVolcano = () => { const genVolcano = (em) => {
let xpos = randRange(0, canvas.width); let xpos = randRange(0, canvas.width);
let time = 0; let time = 0;
const interval = setInterval(()=>{ const interval = setInterval(()=>{
for(let i=0; i<10; ++i) createParticule(ExplosionP, randEmote(), {},{x:xpos,y:canvas.height,angle:30}); for(let i=0; i<10; ++i) createParticule(ExplosionP, em? em:randEmote(), {},{x:xpos,y:canvas.height,angle:30});
++time; ++time;
if(time > 50) clearInterval(interval); if(time > 50) clearInterval(interval);
}, 100); }, 100);
@ -336,13 +336,25 @@ $(async function () {
let rawMessage = e.data, let rawMessage = e.data,
message = JSON.parse(rawMessage); message = JSON.parse(rawMessage);
if(!message.hasOwnProperty('eventFamily') || message.eventFamily != 'emotewall' || if(!message.hasOwnProperty('eventFamily') || message.eventFamily != 'emote' ||
!message.hasOwnProperty('eventType') || !message.hasOwnProperty('data')) !message.hasOwnProperty('eventType') || !message.hasOwnProperty('data'))
return; return;
console.log(message.eventType, message.data) console.log(message.eventType, message.data)
if(message.eventType == 'message') { if(message.eventType == 'bounce') {
//.... createParticule(BounceP, message.data, {}, {})
}else if(message.eventType == 'rain') {
genRain(message.data)
}else if(message.eventType == 'firework') {
genFirework(message.data)
}else if(message.eventType == 'volcano') {
genVolcano(message.data)
}else if(message.eventType == 'bomb') {
createParticule(BombP, message.data, {}, {})
}else if(message.eventType == 'explosion') {
//genExplosion(message.data)
}else {
console.log("unhandled:", message.eventType)
} }
} catch (ex) { } catch (ex) {
console.log(ex) console.log(ex)
@ -353,7 +365,7 @@ $(async function () {
jQuery(async ()=>{ jQuery(async ()=>{
try{ try{
socket.addFamilyHandler("overlay", handleSocketMessage); socket.addFamilyHandler("emote", handleSocketMessage);
if(socket){ if(socket){
while(socket.getReadyState() === 0){ while(socket.getReadyState() === 0){
await new Promise(r => setTimeout(r, 500)); await new Promise(r => setTimeout(r, 500));