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

Add multiple return formats for parsers #2

Closed doceazedo closed 2 years ago

doceazedo commented 2 years ago

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:

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;
}[];