small adjustments

This commit is contained in:
Jörn-Michael Miehe 2023-12-28 21:11:47 +00:00
parent 9eb0976b35
commit ce174d4d2b

View file

@ -28,7 +28,7 @@ async function bttv_get_url(code: string): Promise<Emote> {
return { return {
code: code, code: code,
url: `https://cdn.betterttv.net/emote/${matches[0].id}/1x.${matches[0].imageType}`, url: `//cdn.betterttv.net/emote/${matches[0].id}/1x.${matches[0].imageType}`,
}; };
} }
@ -39,7 +39,7 @@ async function get_emotes(codes: Iterable<string>): Promise<EmoteMap> {
// queue emote jobs // queue emote jobs
const queue = [...codes_set].map((code) => bttv_get_url(code)); const queue = [...codes_set].map((code) => bttv_get_url(code));
console.log("[lmlfc-bttv] queueing", queue.length, "jobs"); console.log("[lmlfc-bttv] queued", queue.length, "jobs");
// run // run
const result: EmoteMap = {}; const result: EmoteMap = {};
@ -52,7 +52,7 @@ async function get_emotes(codes: Iterable<string>): Promise<EmoteMap> {
async function process_text(text: string): Promise<string> { async function process_text(text: string): Promise<string> {
const matches = [...text.matchAll(emote_regex)]; const matches = [...text.matchAll(emote_regex)];
const emotes = await get_emotes(matches.map((elem) => elem[1])); const emotes = await get_emotes(matches.map(([_, code]) => code));
for (const emote of matches.reverse()) { for (const emote of matches.reverse()) {
const [match, code] = emote; const [match, code] = emote;