BlackyWhoElse / streamer.bot-actions

A collection of actions for streamer.bot coded by BlackyWerSonst
https://twitch.tv/Blackywersonst
84 stars 18 forks source link

Issue#89-fix #91

Closed Ziegmaster closed 12 months ago

Ziegmaster commented 12 months ago

Code snippet

let emoteSearchPointer = 0;
let formattedMessage = "";

// Render
message.emotes.forEach((emote) => {

    let searchStr = message.message.substring(emoteSearchPointer);
    let emoteLocation = searchStr.indexOf(emote.name);

    console.log(emoteSearchPointer, searchStr);

    let replacement;

    if (emote.classes.includes("ffzHyper") || emote.classes.includes("ffzSlide")) {
        replacement = `<div class="${emote.classes.join(" ")}" style="background-image:url(${emote.imageUrl})"><div>`;

    } else {
        replacement = `<img class="${emote.classes.join(" ")}" src="${emote.imageUrl}">`
    }

    formattedMessage += searchStr.substring(0, emoteLocation) + replacement + " ";
    emoteSearchPointer += emoteLocation + emote.name.length;
});

if (formattedMessage){
    message.message = formattedMessage + message.message.substring(emoteSearchPointer);
}
Ziegmaster commented 12 months ago

Issue tag just in case

BlackyWhoElse commented 12 months ago