73 lines
2.3 KiB
JavaScript
73 lines
2.3 KiB
JavaScript
(function() {
|
|
|
|
function getEmotes(event, message){
|
|
var emotes = event.getTags().get('emotes'),
|
|
str = message,
|
|
i;
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
function sendData(tpe, data) {
|
|
$.panelsocketserver.sendJSONToAll(JSON.stringify({
|
|
'eventFamily': 'emote',
|
|
'eventType': tpe,
|
|
'data': data
|
|
}));
|
|
}
|
|
|
|
$.bind('ircChannelMessage', function(event){
|
|
var sender = event.getSender(),
|
|
message = event.getMessage().toLowerCase(),
|
|
messageLength = message.length(),
|
|
tags = event.getTags();
|
|
$.consoleLn(message)
|
|
$.consoleLn(tags)
|
|
})
|
|
|
|
$.bind('command', function(event) {
|
|
|
|
const sender = "" + event.getSender().toLowerCase(),
|
|
command = event.getCommand(),
|
|
args = event.getArgs(),
|
|
action = args[0],
|
|
value = args[1];
|
|
|
|
if (command.equalsIgnoreCase('overlay')) {
|
|
if (!action) {
|
|
$.say($.whisperPrefix(sender) + $.lang.get('ew.help', ' Use "!ew [follow | subscribe | donation | timer] value" to set overlay data.'));
|
|
} else if (action.equalsIgnoreCase('follow')) {
|
|
sendData(action, value);
|
|
} else if (action.equalsIgnoreCase('subscribe')) {
|
|
sendData(action, value);
|
|
} else if (action.equalsIgnoreCase('donation')) {
|
|
sendData(action, value);
|
|
} else if (action.equalsIgnoreCase('timer')) {
|
|
sendData(action, new Date(Date.now().getTime()+value*1000*60));
|
|
} else {
|
|
$.say($.whisperPrefix(sender) + $.lang.get('ew.help'));
|
|
}
|
|
}
|
|
});
|
|
|
|
$.bind('twitchFollow', function(event) {
|
|
sendData('follow', event.getFollower());
|
|
});
|
|
$.bind('twitchSubscriber', function(event) {
|
|
sendData('subscribe', event.getSubscriber());
|
|
});
|
|
|
|
$.bind('initReady', function() {
|
|
$.registerChatCommand('./custom/custom/customOverlay.js', 'ew');
|
|
|
|
$.registerChatSubcommand('ew', 'follow', 2);
|
|
});
|
|
|
|
})(); |