Skip to content

Commit

Permalink
fix(emotes): use custom api call to get animated emotes
Browse files Browse the repository at this point in the history
  • Loading branch information
sogehige committed Sep 30, 2022
1 parent 8fbad07 commit 69a2c1c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -11,10 +11,10 @@
"author": "Michal Orlik <sogehige@gmail.com>",
"license": "MIT",
"dependencies": {
"@sogebot/ui-admin": "^65.0.0",
"@sogebot/ui-admin": "^65.1.1",
"@sogebot/ui-helpers": "^3.1.0",
"@sogebot/ui-oauth": "~3.1.1",
"@sogebot/ui-overlay": "^33.0.5",
"@sogebot/ui-overlay": "^33.0.8",
"@sogebot/ui-public": "^4.0.0",
"@twurple/api": "^5.2.4",
"@twurple/auth": "^5.2.4",
Expand Down Expand Up @@ -57,7 +57,7 @@
"mysql2": "2.3.3",
"node-fetch": "^2.6.6",
"npm-check-updates": "^16.3.2",
"obs-websocket-js": "5.0.1",
"obs-websocket-js": "5.0.2",
"patch-package": "6.4.7",
"pg": "8.8.0",
"proxy-deep": "3.1.1",
Expand Down Expand Up @@ -162,7 +162,7 @@
"test-until": "1.1.1",
"tsc-alias": "^1.7.0",
"tsconfig-paths": "^4.1.0",
"typescript": "4.8.3",
"typescript": "4.8.4",
"url-regex": "5.0.0",
"util": "0.12.4"
},
Expand Down
20 changes: 12 additions & 8 deletions src/emotes.ts
Expand Up @@ -162,18 +162,22 @@ class Emotes extends Core {
info(`EMOTES: Fetching channel ${broadcasterId} emotes`);
}
const apiClient = await client('broadcaster');
const emotes = await apiClient.chat.getChannelEmotes(broadcasterId);
const emotes = await apiClient.callApi<any>({ url: `chat/emotes?broadcaster_id=${broadcasterId}`, type: 'helix' });
this.lastSubscriberEmoteChk = Date.now();
this.cache = this.cache.filter(o => o.type !== 'twitch-sub');
for (const emote of emotes) {
for (const emote of (emotes.data || [])) {
debug('emotes.channel', `Saving to cache ${emote.name}#${emote.id}`);
const template = emotes.template
.replace('{{id}}', emote.id)
.replace('{{format}}', emote.format.includes('animated') ? 'animated' : 'static')
.replace('{{theme_mode}}', 'dark');
this.cache.push({
code: emote.name,
type: 'twitch',
urls: {
'1': emote.getImageUrl(1).replace('/static/', '/default/'), // enables animation
'2': emote.getImageUrl(2).replace('/static/', '/default/'), // enables animation
'3': emote.getImageUrl(4).replace('/static/', '/default/'), // enables animation
'1': template.replace('{{scale}}', '1.0'),
'2': template.replace('{{scale}}', '2.0'),
'3': template.replace('{{scale}}', '3.0'),
},
});
}
Expand Down Expand Up @@ -219,9 +223,9 @@ class Emotes extends Core {
code: emote.name,
type: 'twitch',
urls: {
'1': emote.getImageUrl(1).replace('/static/', '/default/'),
'2': emote.getImageUrl(2).replace('/static/', '/default/'),
'3': emote.getImageUrl(4).replace('/static/', '/default/'),
'1': emote.getImageUrl(1),
'2': emote.getImageUrl(2),
'3': emote.getImageUrl(4),
},
});
}
Expand Down

0 comments on commit 69a2c1c

Please sign in to comment.