💬 A Twitch (BTTV and FFZ) emotes and badges parser - built with tmi.js in mind

Overview

emoteTTV

npm install size downloads snyk snyk

  • Works with Twitch, BTTV and FFZ emotes
  • Dead simple API - works seamlessly with TMI.js
  • Flexible results to fit every need

Demo

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

Installation

npm install emotettv
# or with yarn
yarn add emotettv
import { parseBadges, parseEmotes, ... } from 'emotettv';

Usage

🚨 Remember to always sanitize user messages! If your frontend library doesn't do that for you, I recommend using DOMPurify.

parseEmotes(...)

Returns the initial message as an array of words and emotes.

Parameters

  • message string - Message string to parse
  • emotes EmotePositions - List of emote positions, like tmi.js tags.emotes
  • channelId string - Twitch ID of the channel the message is from

Returns: Promise<Word[]>

parseBadges(...)

Returns an object with the user badges

Parameters

  • badgesData Badges - List of the user badges, like tmi.js tags.badges
  • channelId string - Twitch ID of the channel the message is from

Returns: Promise<ParsedBadges>

Building

git clone https://github.com/doceazedo/emotettv.git
cd emotettv
npm install # or yarn
npm run build # or yarn build

License

The emoteTTV project is licensed under the GPLv3 License.

Comments
  • parseEmotes options (and custom emote factories)

    parseEmotes options (and custom emote factories)

    Add an options parameter for more flexibility and remove channelId in favor of it.

    type ParseEmotesOptions = {
      channelId?: string;
      thirdPartyProviders?: {
        bttv?: boolean;
        ffz?: boolean;
      };
      customEmotes: EmotesFactory | EmotesFactory[]
    }
    

    Descriptions:

    • channelId being optional will allow the use of only global or custom emotes
    • thirdPartyProviders will allow to toggle third-party emotes and help adding others in the future
    • customEmotes will allow the use of custom emote factories, provided by the user

    All third-party providers will be defaulted to true.

    opened by doceazedo 0
  • Add different platforms compatibility

    Add different platforms compatibility

    Setup cross-fetch to make the library compatible with browsers, Node and React Native. I think it would be better to use it as a polyfill, but not sure if there are any drawbacks.

    good first issue 
    opened by doceazedo 0
  • Organize modules, services and their types

    Organize modules, services and their types

    • The ffz service should be merged with the bttv one, as they use the same API.
    • The services folder shall be deleted and its files moved to their related modules, renamed as <module>.service.ts.
    • Every module that uses custom types shall have a <module>.types.ts file exporting all of its types.
    opened by doceazedo 0
  • Add multiple return formats for parsers

    Add multiple return formats for parsers

    Instead of the parseEmotes and parseBadges functions returning their parsing results based on predefined formats, multiple chain functions shall be added to return different formats.

    The following methods will be responsible for returning the internal parsed formats - the ones that are currently returned by default:

    • parseEmotes(...).toWords()
    • parseBadges(...).toBasicArray()

    The following methods shall be implemented to return different formats for user convenience:

    Method:

    parseEmotes(...).toHtml(size?: number) => Promise<string>
    

    Description: Returns a string with the original message and emote codes converted to <img>

    Input: Hi HeyGuys I'm an example message! popCat

    Output:

    Hi <img src="..." alt="HeyGuys" /> I'm an example message! <img src="..." alt="popCat" />
    

    Method:

    parseBadges(...).toHtml(size?: number) => Promise<string>
    

    Description: Returns a string with the user badges converted to <img>

    Output:

    <img src="..." alt="broadcast" /> <img src="..." alt="subscriber" /> <img src="..." alt="premium" />
    

    Method:

    parseBadges(...).toMinimalArray() => Promise<BadgesMinimalArray>
    

    Description: Returns a simplified version of the badges array, with only the image URLs in all sizes

    Output:

    type BadgesMinimalArray = {
      image_url_1x: string;
      image_url_2x: string;
      image_url_4x: string;
    }[];
    
    opened by doceazedo 0
  • Split channel and global emote stores

    Split channel and global emote stores

    If emotettv is used to parse messages from different channels, the store of every channel emotes will have their own copy of the global emotes yet they could be shared.

    My proposal is to add a globaEmotesStore alongside channelEmotesStore.

    This could also be achieved by adding a global key alongside the other channel IDs in the channelEmotesStore, but I think the first option is more elegant.

    opened by doceazedo 1
  • Allow (re)loading and clearing emotes/badges

    Allow (re)loading and clearing emotes/badges

    Add these methods to the lib:

    • reloadEmotes(options)
    • clearEmotes()
    • reloadBadges(options)
    • clearBadges()

    The reload functions should expect those same options of type ParseEmotesOptions described on issue #10.

    As this wouldn't break any existing code, it could probably be delayed to later v1 release.

    opened by doceazedo 0
  • Create documentation

    Create documentation

    I'm totally open to suggestions on the best way to document this project :) These are some of the alternatives I was thinking of:

    • Just create some Markdown files on a "docs" folder
    • Use Docz or some other alternative
    • Create a static website with Astro

    If we create a static website for the docs, It would be cool to get all the info the we can automatically.

    help wanted 
    opened by doceazedo 0
  • Setup GitHub Actions

    Setup GitHub Actions

    It would be nice to have an action to run these steps on every pull request open:

    • Run linting and formatting checks
    • Run Jest tests (yet to be created on: #6)
    • Run build

    And an action to run these on creating a new release:

    • Run build
    • Bump version (according to the release)
    • Publish package to NPM
    help wanted 
    opened by doceazedo 1
Owner
Lucas Fernandes
19, curiosity-driven developer, Svelte evangelist, building web apps, coding and solving problems live at Twitch and whatnot
Lucas Fernandes
Json-parser - A parser for json-objects without dependencies

Json Parser This is a experimental tool that I create for educational purposes, it's based in the jq works With this tool you can parse json-like stri

Gabriel Guerra 1 Jan 3, 2022
Useful GitHub Badges and based on serverless! 🚀

serverless-github-badges This project is inspired by puf17640/git-badges, but built with the serverless stack: Cloudflare Workers and Cloudflare Worke

Zhou Zhiqiang 38 Dec 20, 2022
Bootstrap5-tags - Replace select[multiple] with nices badges

Tags for Bootstrap 4/5 How to use An ES6 native replacement for select using standards Bootstrap 5 (and 4) styles. No additional CSS needed! Supports

Thomas Portelange 75 Jan 9, 2023
Make use of your favicon with badges, images or videos

favico.js More info here. Author Miroslav Magda Version 0.3.9 Contributors: Serge Barysiuk, pissflaps, Yaroslav Yakovlev, LoicMahieu, Renan Gonçalves,

Miroslav Magda 8.7k Dec 21, 2022
This plugin integrates by default with Twitter bootstrap using badges to display the maximum lenght of the field where the user is inserting text. Uses the HTML5 attribute "maxlength" to work.

Bootstrap MaxLength This plugin integrates by default with Twitter bootstrap using badges to display the maximum length of the field where the user is

Maurizio 772 Dec 25, 2022
A meditating website to clear your mind. Built with Next.JS and TailwindCSS ♥

Meditate A modern meditation web app for you to meditate on your own terms. Track your progress and share your thoughts with others. Table of Contents

Andy 5 Jul 27, 2022
The open source Community Operating System, built with developers in mind.

IMPORTANT: This project is still under active development. Be aware that future releases can lead to breaking changes. The open source Community OS, b

crowd.dev 383 Dec 29, 2022
A bot built for Twitch.tv by EspressoStudios

Readme.md Documentation Version: 1.2.0 Twith bot version: 1.2.0 Current prefix: ! Prefix can be changed in the config.json file, in the 'prefix' form.

null 1 Jan 18, 2022
A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

A free and open source resume builder. Go to App What is this app all about? Reactive Resume is a free and open source resume builder that’s built to

Reactive Resume 9.7k Jan 3, 2023
A Hackable Markdown Note Application for Programmers. Version control, AI completion, mind map, documents encryption, code snippet running, integrated terminal, chart embedding, HTML applets, plug-in, and macro replacement.

Yank Note A hackable markdown note application for programmers Download | Try it Online >>> Not ecommended English | 中文说明 [toc]{level: [2]} Highlights

洋子 4.3k Dec 31, 2022
Always with personal privacy and anonymity in mind.

Clodbunker At the moment we aim to be a cutting-edge service that provides anonymous and secure cloud storage, with a strong focus on end-to-end encry

Cloudbunker 4 Mar 15, 2023
Change the color of an image to a specific color you have in mind.

image-recolor Run it: https://image-recolor.vercel.app/ image.recolor.mov Acknowledgments Daniel Büchele for the algorithm: https://twitter.com/daniel

Christopher Chedeau 21 Oct 25, 2022
Secure-electron-template - The best way to build Electron apps with security in mind.

secure-electron-template A current electron app template with the most popular frameworks, designed and built with security in mind. (If you are curio

reZach 1.4k Dec 29, 2022
A social network that simulates a personal blog, where people post "What's on your mind?". Tweteroo is a Twitter clone.

Tweteroo About A social network that simulates a personal blog, where people post "What's on your mind?". Tweteroo is a Twitter clone. ?? Features ☑️

Luiza Santiago 5 Apr 13, 2022
Mind Mapping to excel, or excel to .xmind file

Mind Mapping To Excel Project setup Prepare project npm install 1、Fetch data and generate excel Open the Mind Mapping like this Process On Mind Mappi

xuzelin995 3 May 5, 2022
A RabbitMQ client for TypeScript, with functional programming in mind.

RabbitMQ-fp Lets feed our Rabbit' nicely ?? This repository contains a wrapper over amqplib written in Typescript with an accent of functionnal progra

MansaGroup 3 Sep 6, 2022
A markdown parser and compiler. Built for speed.

Marked ⚡ built for speed ⬇️ low-level compiler for parsing markdown without caching or blocking for long periods of time ⚖️ light-weight while impleme

Marked 28.9k Jan 7, 2023
This repo is a collection of code samples and links to previous twitch live stream sessions. If you have any ideas or suggestions for future episodes, feel free to open an issue.

Talk DEV to me Talk DEV to me is a monthly show on twitch.tv/aws hosted by Tiago Barbosa and Alex Melnyk, where we invite customers, partners, or Amaz

AWS Samples 122 Jan 6, 2023
You view the Twitch channel chat and you can access the details of the users who wrote during the viewing period.

Twitch Chat Web Page You view the Twitch channel chat and you can access the details of the users who wrote during the viewing period. Getting Started

Mert 6 Dec 13, 2022