diff --git a/src/modules/misc.js b/src/modules/misc.js index d08ef97..5032a70 100644 --- a/src/modules/misc.js +++ b/src/modules/misc.js @@ -281,6 +281,9 @@ anonradio.callback = async function (msg, line) { const schedule = await fetch("https://anonradio.net/schedule/").then((res) => res.text() ); + const icecast = await fetch("http://anonradio.net:8010/status-json.xsl").then( + (res) => res.json() + ); let lines = schedule.split("\n"); lines = lines.slice(4, lines.length - 2); @@ -345,6 +348,19 @@ anonradio.callback = async function (msg, line) { subtitle = `${current} listening with a daily peak of ${peakDay} and ${peakMonth} peak for the month.`; } + let openmicTime = ""; + if (liveNow.id == "openmic") { + const streamData = icecast.icestats.source.find( + (src) => src.listenurl == "http://anonradio.net:8010/openmic" + ); + if (streamData && streamData.stream_start_iso8601) { + const startTime = new Date(streamData.stream_start_iso8601).getTime(); + openmicTime = `-*- OpenMIC DJ has been streaming for ${formatTime( + Date.now() - startTime + )} -*-\n`; + } + } + return { embeds: [ { @@ -353,7 +369,7 @@ anonradio.callback = async function (msg, line) { name: title, url: "http://anonradio.net:8000/anonradio", }, - description: "__Schedule:__", + description: openmicTime + "__Schedule:__", fields: parsedLines.map((line) => ({ inline: true, name: `${line.name} (\`${line.id}\`)`,