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);
 | 
					hf.registerCommand(vote);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const DAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
 | 
					const DAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
 | 
				
			||||||
const arsched = new Command("arsched");
 | 
					const anonradio = new Command("anonradio");
 | 
				
			||||||
arsched.category = CATEGORY;
 | 
					anonradio.category = CATEGORY;
 | 
				
			||||||
arsched.helpText = "aNONradio.net schedule";
 | 
					anonradio.helpText = "aNONradio.net schedule";
 | 
				
			||||||
arsched.addAlias("anonradio");
 | 
					anonradio.callback = async function (msg, line) {
 | 
				
			||||||
arsched.callback = async function (msg, line) {
 | 
					 | 
				
			||||||
  const now = new Date();
 | 
					  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) =>
 | 
					  const schedule = await fetch("https://anonradio.net/schedule/").then((res) =>
 | 
				
			||||||
    res.text()
 | 
					    res.text()
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
| 
						 | 
					@ -320,14 +322,34 @@ arsched.callback = async function (msg, line) {
 | 
				
			||||||
  const liveNow = parsedLines.splice(0, 1)[0];
 | 
					  const liveNow = parsedLines.splice(0, 1)[0];
 | 
				
			||||||
  liveNow.name = liveNow.name.replace("  <- Live NOW", "");
 | 
					  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 {
 | 
					  return {
 | 
				
			||||||
    embeds: [
 | 
					    embeds: [
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        title: "Click to listen",
 | 
					        title: subtitle,
 | 
				
			||||||
        url: "http://anonradio.net:8000/anonradio",
 | 
					 | 
				
			||||||
        author: {
 | 
					        author: {
 | 
				
			||||||
          name: `LIVE NOW: ${liveNow.name} (\`${liveNow.id}\`)`,
 | 
					          name: title,
 | 
				
			||||||
 | 
					          url: "http://anonradio.net:8000/anonradio",
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
 | 
					        description: "__Schedule:__",
 | 
				
			||||||
        fields: parsedLines.map((line) => ({
 | 
					        fields: parsedLines.map((line) => ({
 | 
				
			||||||
          inline: true,
 | 
					          inline: true,
 | 
				
			||||||
          name: `${line.name} (\`${line.id}\`)`,
 | 
					          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 REGEX_IPV4 = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/;
 | 
				
			||||||
const shodan = new Command("shodan");
 | 
					const shodan = new Command("shodan");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue