![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
@mkody/twitch-emoticons
Advanced tools
Gets Twitch, BTTV, FFZ and 7TV emotes as well as parsing text to emotes!
Gets Twitch, BTTV, FFZ and 7TV emotes as well as parsing text to emotes!
You must now use a Twitch user ID instead of the username to fetch user's emotes.
You can use this page to quickly grab it.
To fetch Twitch emotes you need to get a client and secret from Twitch here, it's free.
If you are only using BetterTTV, FrankerFaceZ and 7TV you don't need to provide Twitch app keys as they are independent from the Twitch API.
npm install @mkody/twitch-emoticons
# or
yarn add @mkody/twitch-emoticons
// With ESM import
import TwitchEmoticons from '@mkody/twitch-emoticons';
const { EmoteFetcher, EmoteParser } = TwitchEmoticons;
// ... or require()
const { EmoteFetcher, EmoteParser } = require('@mkody/twitch-emoticons');
// Your Twitch app keys
const clientId = '<your client id>';
const clientSecret = '<your client secret>';
const fetcher = new EmoteFetcher(clientId, clientSecret);
const parser = new EmoteParser(fetcher, {
type: 'markdown',
match: /:(.+?):/g
});
fetcher.fetchTwitchEmotes(null).then(() => {
const kappa = fetcher.emotes.get('Kappa').toLink();
console.log(kappa);
// https://static-cdn.jtvnw.net/emoticons/v2/25/default/dark/1.0
const text = 'Hello :CoolCat:!';
const parsed = parser.parse(text);
console.log(parsed);
// Hello ![CoolCat](https://static-cdn.jtvnw.net/emoticons/v2/58127/default/dark/1.0 "CoolCat")!
});
@twurple/api
If you already use Twurple in your project and manage authentification
(i.e. with user tokens), you can reuse it in this project by skipping the first two paramters and
setting apiClient
with your ApiClient object.
const fetcher = new EmoteFetcher(null, null, {
apiClient: yourOwnTwurpleApiClientHere
});
const { EmoteFetcher, EmoteParser } = require('@mkody/twitch-emoticons');
// Your channel ID
const channelId = 44317909;
// Your Twitch app keys
const clientId = '<your client id>';
const clientSecret = '<your client secret>';
const fetcher = new EmoteFetcher(clientId, clientSecret);
const parser = new EmoteParser(fetcher, {
// Custom HTML format
template: '<img class="emote" alt="{name}" src="{link}">',
// Match without :colons:
match: /(\w+)+?/g
});
Promise.all([
// Twitch global
fetcher.fetchTwitchEmotes(),
// Twitch channel
fetcher.fetchTwitchEmotes(channelId),
// BTTV global
fetcher.fetchBTTVEmotes(),
// BTTV channel
fetcher.fetchBTTVEmotes(channelId),
// 7TV global
fetcher.fetchSevenTVEmotes(),
// 7TV channel
fetcher.fetchSevenTVEmotes(channelId),
// FFZ global
fetcher.fetchFFZEmotes(),
// FFZ channel
fetcher.fetchFFZEmotes(channelId)
]).then(() => {
const globalEmotes = parser.parse('EZ Clap way too easy LUL now for the last boss monkaS LaterSooner');
console.log(globalEmotes);
// <img class="emote" alt="EZ" src="https://cdn.7tv.app/emote/63071b80942ffb69e13d700f/1x.webp"> <img class="emote" alt="Clap" src="https://cdn.7tv.app/emote/62fc0a0c4a75fd54bd3520a9/1x.webp"> way too easy <img class="emote" alt="LUL" src="https://static-cdn.jtvnw.net/emoticons/v2/425618/default/dark/1.0"> now for the last boss <img class="emote" alt="monkaS" src="https://cdn.betterttv.net/emote/56e9f494fff3cc5c35e5287e/1x.webp"> <img class="emote" alt="LaterSooner" src="https://cdn.frankerfacez.com/emote/149346/1">
const channelEmotes = parser.parse('KEKW that was 3Head TeriPoint');
console.log(channelEmotes);
// <img class="emote" alt="KEKW" src="https://cdn.betterttv.net/emote/5e9c6c187e090362f8b0b9e8/1x.webp"> that was <img class="emote" alt="3Head" src="https://cdn.frankerfacez.com/emote/274406/1"> <img class="emote" alt="TeriPoint" src="https://cdn.7tv.app/emote/61dc299b600369a98b38ebef/1x.webp">
}).catch(err => {
console.error('Error loading emotes...');
console.error(err);
});
7TV v3 delivers emotes in either WEBP or AVIF.
By default we'll return WEBP emotes but you can override this.
const { EmoteFetcher } = require('@mkody/twitch-emoticons');
const fetcher = new EmoteFetcher();
// Fetch global emotes in AVIF (channel id has to be `null` for global)
await fetcher.fetchSevenTVEmotes(null, 'avif');
// Fetch 0kody's emotes with the package's default format (WEBP)
await fetcher.fetchSevenTVEmotes(44317909);
// ... which is currently the same as
await fetcher.fetchSevenTVEmotes(44317909, 'webp');
// Fetch Anatole's emotes in AVIF
await fetcher.fetchSevenTVEmotes(24377667, 'avif');
This can be useful to save the emotes in a cache or for offline content.
(For offline content, you'll still need to download emotes and proxy their URLs.)
const { EmoteFetcher } = require('@mkody/twitch-emoticons');
const fetcher = new EmoteFetcher();
// First fetch some emotes
await fetcher.fetchSevenTVEmotes(null, 'avif');
// Then you can use .toObject() on an `Emote` to export its data.
// Here's a map to get them all in a single array.
const emotes = fetcher.emotes.map(emote => emote.toObject());
// Later, with or without a fresh `EmoteFetcher`, you can use .fromObject() on the fetcher.
fetcher.fromObject(emotes);
This library uses the following:
FAQs
Gets Twitch, BTTV, FFZ and 7TV emotes as well as parsing text to emotes!
The npm package @mkody/twitch-emoticons receives a total of 59 weekly downloads. As such, @mkody/twitch-emoticons popularity was classified as not popular.
We found that @mkody/twitch-emoticons demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.