From a3cf7aabee69296ae5e01c35bd1076461d1918dc Mon Sep 17 00:00:00 2001 From: Cynthia Date: Sun, 18 Dec 2022 13:04:20 -0700 Subject: [PATCH 1/5] anonradio: fix empty slots --- src/modules/anonradio.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/anonradio.js b/src/modules/anonradio.js index e163e7b..a1f340a 100644 --- a/src/modules/anonradio.js +++ b/src/modules/anonradio.js @@ -55,6 +55,8 @@ async function updateNowPlaying() { if (playing.includes("listeners with a daily peak of")) { title = `${liveNow.name} (\`${liveNow.id}\`)`; subtitle = playing; + } else if (playing.startsWith("Coming up")) { + title = playing; } else { const [_, current, peakDay, peakMonth, dj, metadata] = playing.match( /\[(\d+)\/(\d+)\/(\d+)\] \((.+?)\): (.+)/ From f77466831b29b6902282ad24b33d176d5e10a599 Mon Sep 17 00:00:00 2001 From: Cynthia Date: Sun, 18 Dec 2022 15:01:50 -0700 Subject: [PATCH 2/5] . --- src/modules/anonradio.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/anonradio.js b/src/modules/anonradio.js index a1f340a..bcbad60 100644 --- a/src/modules/anonradio.js +++ b/src/modules/anonradio.js @@ -40,6 +40,8 @@ async function updateNowPlaying() { lines = lines.slice(4, lines.length - 2); const line = lines[0]; + if (!line) return; + const [_, _time, id, name] = line.match(/^(.{3,4} .{4})\s+(.+?) {2}(.+?)$/); const liveNow = {name: "ident", id: "aNONradio"}; From 0f3e029430c8e720e2b783ea3ce27be027d3ef2b Mon Sep 17 00:00:00 2001 From: Cynthia Date: Mon, 19 Dec 2022 10:33:17 -0700 Subject: [PATCH 3/5] anonradio: attempt to reduce gradual edit spam --- src/modules/anonradio.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/modules/anonradio.js b/src/modules/anonradio.js index bcbad60..fc0673a 100644 --- a/src/modules/anonradio.js +++ b/src/modules/anonradio.js @@ -99,10 +99,21 @@ async function updateNowPlaying() { const content = `${title}\n${subtitle}\n${openmicTime}`.trim(); const thread = hf.bot.guilds.get(GUILD_ID).threads.get(THREAD_ID); - const msg = await thread.getMessage(MESSAGE_ID); - if (msg.content !== content) { - thread.editMessage(MESSAGE_ID, {content}); + if (thread) { + const msg = await thread.getMessage(MESSAGE_ID); + if (msg.content !== content) { + await thread.editMessage(MESSAGE_ID, {content}); + } } } -hf.timer.add("anonradio", updateNowPlaying, 2000); +hf.timer.add( + "anonradio", + async () => { + await new Promise((resolve, reject) => { + setTimeout(() => reject("timeout"), 1900); + updateNowPlaying().then(() => resolve(true)); + }).catch(() => {}); + }, + 2000 +); From bb597279b560b20dec2ab665bc55d09dd0680ed9 Mon Sep 17 00:00:00 2001 From: Cynthia Date: Mon, 19 Dec 2022 18:20:30 -0700 Subject: [PATCH 4/5] fedimbed: fix newlines yet again --- src/modules/fedimbed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/fedimbed.js b/src/modules/fedimbed.js index ec9e807..0b210df 100644 --- a/src/modules/fedimbed.js +++ b/src/modules/fedimbed.js @@ -289,7 +289,7 @@ async function processUrl(msg, url) { cw = cw ?? ""; // TODO: convert certain HTML tags back to markdown - content = content.replace(/
/g, "\n"); + content = content.replace(/<\/?\s*br\s*\/?>/g, "\n"); content = content.replace(/<\/p>

/g, "\n\n"); content = content.replace(/(<([^>]+)>)/gi, ""); content = parseHtmlEntities(content); From a430d0d1ed171afc1fa263abdd02c279f4eec51d Mon Sep 17 00:00:00 2001 From: Cynthia Date: Tue, 20 Dec 2022 11:27:26 -0700 Subject: [PATCH 5/5] lib.unicode: use www --- src/lib/unicode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/unicode.js b/src/lib/unicode.js index a4db5b4..d1ae9f6 100644 --- a/src/lib/unicode.js +++ b/src/lib/unicode.js @@ -2,7 +2,7 @@ const mappings = {}; async function cacheList() { const data = await fetch( - "https://unicode.org/Public/UNIDATA/UnicodeData.txt" + "https://www.unicode.org/Public/UNIDATA/UnicodeData.txt" ).then((res) => res.text()); data