phantombot-plugins/twitch/customEmoteWall.js

78 lines
3.0 KiB
JavaScript
Raw Normal View History

2022-02-19 00:48:41 +01:00
(function() {
2022-02-23 19:38:39 +01:00
function getNoTwitchEmotes(event, message){
2022-02-19 00:48:41 +01:00
var emotes = event.getTags().get('emotes'),
2022-02-23 19:38:39 +01:00
str = message, i;
2022-02-19 00:48:41 +01:00
if (emotes.length() > 0) {
emotes = emotes.replaceAll('[0-9]+:', '').split('/');
for (i in emotes) {
str = str.replace(getWordAt(message, parseInt(emotes[i].split('-')[0])), '');
}
}
return str;
}
2022-02-23 19:38:39 +01:00
function sendData(tpe, te, ce) {
2022-02-19 00:48:41 +01:00
$.panelsocketserver.sendJSONToAll(JSON.stringify({
'eventFamily': 'emote',
'eventType': tpe,
2022-02-23 19:38:39 +01:00
'data': {
twitch: te,
custom: ce,
}
2022-02-19 00:48:41 +01:00
}));
}
$.bind('ircChannelMessage', function(event){
var sender = event.getSender(),
2022-02-23 19:38:39 +01:00
message = event.getMessage();
2022-02-19 00:48:41 +01:00
tags = event.getTags();
2022-02-23 19:38:39 +01:00
if(messsage[0] != '!')
sendData('bounce',event.getTags().get('emotes'), getNoTwitchEmotes(event,message))
2022-02-19 00:48:41 +01:00
})
$.bind('command', function(event) {
const sender = "" + event.getSender().toLowerCase(),
command = event.getCommand(),
args = event.getArgs(),
2022-02-23 19:38:39 +01:00
action = args[0];
2022-02-19 00:48:41 +01:00
2022-02-23 19:38:39 +01:00
if (command.equalsIgnoreCase('ew')) {
2022-02-19 00:48:41 +01:00
if (!action) {
2022-02-23 19:38:39 +01:00
$.say($.whisperPrefix(sender) + $.lang.get('ew.help', ' Use "!ew [rain | firework | volcano | bomb | explosion] emote" to render emotes.'));
} else if (action.equalsIgnoreCase('rain')) {
2022-02-23 19:41:01 +01:00
sendData('rain',event.getTags().get('emotes'), getNoTwitchEmotes(event,event.getMessage()))
2022-02-23 19:38:39 +01:00
} else if (action.equalsIgnoreCase('firework')) {
2022-02-23 19:41:01 +01:00
sendData('firework',event.getTags().get('emotes'), getNoTwitchEmotes(event,event.getMessage()))
2022-02-23 19:38:39 +01:00
} else if (action.equalsIgnoreCase('volcano')) {
2022-02-23 19:41:01 +01:00
sendData('volcano',event.getTags().get('emotes'), getNoTwitchEmotes(event,event.getMessage()))
2022-02-23 19:38:39 +01:00
} else if (action.equalsIgnoreCase('bomb')) {
2022-02-23 19:41:01 +01:00
sendData('bomb',event.getTags().get('emotes'), getNoTwitchEmotes(event,event.getMessage()))
2022-02-23 19:38:39 +01:00
} else if (action.equalsIgnoreCase('explosion')) {
2022-02-23 19:41:01 +01:00
sendData('explosion',event.getTags().get('emotes'), getNoTwitchEmotes(event,event.getMessage()))
2022-02-19 00:48:41 +01:00
} else {
2022-02-23 19:38:39 +01:00
$.say($.whisperPrefix(sender) + $.lang.get('ew.help', ' Use "!ew [rain | firework | volcano | bomb | explosion] emote" to render emotes.'));
2022-02-19 00:48:41 +01:00
}
}
});
$.bind('twitchFollow', function(event) {
2022-02-23 19:38:39 +01:00
sendData('firework', [],['AYAYA'])
2022-02-19 00:48:41 +01:00
});
$.bind('twitchSubscriber', function(event) {
2022-02-23 19:38:39 +01:00
sendData('volcano', [], ['AYAYA']);
2022-02-19 00:48:41 +01:00
});
$.bind('initReady', function() {
2022-02-23 08:43:18 +01:00
$.registerChatCommand('./custom/custom/customOverlay.js', 'ew');
2022-02-23 19:38:39 +01:00
$.registerChatSubcommand('ew', 'rain', 2);
$.registerChatSubcommand('ew', 'firework', 2);
$.registerChatSubcommand('ew', 'volcano', 2);
$.registerChatSubcommand('ew', 'bomb', 2);
$.registerChatSubcommand('ew', 'explosion', 2);
2022-02-19 00:48:41 +01:00
});
})();