Created
April 22, 2017 09:23
-
-
Save kocisov/d736b14380f925443f40a78026e12d8d to your computer and use it in GitHub Desktop.
emoteParserLUL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import parse from 'twitch-emoji'; | |
import bttv from './bttv.json'; // https://api.betterttv.net/emotes | |
// it's a mess, just... don't... please... save us | |
function emoteParser (msg) { | |
let _msg = msg; | |
msg.split(/\s+/).map(t => { | |
bttv.emotes.filter(emote => t === emote.regex).map(e => { | |
if (e.url && e.url.length > 0) { | |
_msg = msg.replace( | |
t, | |
`<img className="twitch-emoji" src="${e.url}" alt="">` | |
); | |
} | |
}); | |
}); | |
// also parse Twitch's global emotes (handled by twitch-emoji package) | |
return parse(_msg, { | |
emojiSize: 'small', | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment