doceazedo / emotettv

💬 A Twitch (BTTV, FFZ & 7TV) emotes and badges parser - built with TMI.js in mind
https://emotettv.gitbook.io
17 stars 0 forks source link
7tv bttv emotes ffz javascript library parser tmi tmijs twitch twurple typescript

emoteTTV

npm install size downloads snyk snyk

Demo

Checkout this demo app to see emoteTTV in action! ⛹️

Basic usage

import { parseEmotes } from "emotettv";

const parsed = await parseEmotes("Hello emotettv! D:");
console.log(parsed.toHTML());
// > Hello emotettv! <figure><img src="https://github.com/doceazedo/emotettv/raw/main/.." alt="D:" /></figure>

If you're using TMI.js, you can pass your tags directly to emoteTTV:

import { parseBadges, parseEmotes } from "emotettv";
import tmi from "tmi.js";

const client = new tmi.Client({
  channels: ["doceazedo911"],
});

const options = {
  channelId: "98776633",
};

client.connect();
client.on("message", async (channel, tags, text, self) => {
  const badges = await parseBadges(tags.badges, tags.username, options);
  const message = await parseEmotes(text, tags.emotes, options);
  const htmlBadges = badges.toHTML();
  const htmlMessage = message.toHTML();
  const displayName = tags["display-name"];
  document.body.innerHTML = `${htmlBadges} ${displayName}: ${htmlMessage}`;
});

Docs

Check more examples and API reference on the emoteTTV docs.

License

The emoteTTV project is licensed under the GPLv3 License.