misc.anonradio: pull metadata
This commit is contained in:
parent
7231dea945
commit
352f928660
1 changed files with 31 additions and 9 deletions
|
@ -269,13 +269,15 @@ vote.callback = async function (msg, line) {
|
|||
hf.registerCommand(vote);
|
||||
|
||||
const DAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
||||
const arsched = new Command("arsched");
|
||||
arsched.category = CATEGORY;
|
||||
arsched.helpText = "aNONradio.net schedule";
|
||||
arsched.addAlias("anonradio");
|
||||
arsched.callback = async function (msg, line) {
|
||||
const anonradio = new Command("anonradio");
|
||||
anonradio.category = CATEGORY;
|
||||
anonradio.helpText = "aNONradio.net schedule";
|
||||
anonradio.callback = async function (msg, line) {
|
||||
const now = new Date();
|
||||
|
||||
const playing = await fetch("https://anonradio.net/playing").then((res) =>
|
||||
res.text()
|
||||
);
|
||||
const schedule = await fetch("https://anonradio.net/schedule/").then((res) =>
|
||||
res.text()
|
||||
);
|
||||
|
@ -320,14 +322,34 @@ arsched.callback = async function (msg, line) {
|
|||
const liveNow = parsedLines.splice(0, 1)[0];
|
||||
liveNow.name = liveNow.name.replace(" <- Live NOW", "");
|
||||
|
||||
let title = "";
|
||||
let subtitle = "";
|
||||
|
||||
if (playing.includes("listeners with a daily peak of")) {
|
||||
title = `${liveNow.name} (\`${liveNow.id}\`)`;
|
||||
subtitle = playing;
|
||||
} else {
|
||||
const [_, current, peakDay, peakMonth, dj, metadata] = playing.match(
|
||||
/\[(\d+)\/(\d+)\/(\d+)\] \((.+?)\): (.+?)/
|
||||
);
|
||||
|
||||
if (metadata == "https://archives.anonradio.net") {
|
||||
title = `${liveNow.name} (\`${dj}\`)`;
|
||||
} else {
|
||||
title = `${metadata} (\`${dj}\`)`;
|
||||
}
|
||||
subtitle = `${current} listening with a daily peak of ${peakDay} and ${peakMonth} peak for the month.`;
|
||||
}
|
||||
|
||||
return {
|
||||
embeds: [
|
||||
{
|
||||
title: "Click to listen",
|
||||
url: "http://anonradio.net:8000/anonradio",
|
||||
title: subtitle,
|
||||
author: {
|
||||
name: `LIVE NOW: ${liveNow.name} (\`${liveNow.id}\`)`,
|
||||
name: title,
|
||||
url: "http://anonradio.net:8000/anonradio",
|
||||
},
|
||||
description: "__Schedule:__",
|
||||
fields: parsedLines.map((line) => ({
|
||||
inline: true,
|
||||
name: `${line.name} (\`${line.id}\`)`,
|
||||
|
@ -337,7 +359,7 @@ arsched.callback = async function (msg, line) {
|
|||
],
|
||||
};
|
||||
};
|
||||
hf.registerCommand(arsched);
|
||||
hf.registerCommand(anonradio);
|
||||
|
||||
const REGEX_IPV4 = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/;
|
||||
const shodan = new Command("shodan");
|
||||
|
|
Loading…
Reference in a new issue