add xeno canto command

This commit is contained in:
lolcat 2023-11-24 18:00:50 -06:00
parent 0fb77515b7
commit c8efc9bdd1
1 changed files with 52 additions and 3 deletions

View File

@ -148,7 +148,7 @@ async function serveddg(msg, results, page){
/* /*
Websocket functions Websocket functions
*/ */
async function send(channel, text, file = null){ async function send(channel, text, file = null, forcemime = null){
if(typeof channel == "object"){ if(typeof channel == "object"){
@ -169,7 +169,13 @@ async function send(channel, text, file = null){
/* /*
Send file Send file
*/ */
if(forcemime === null){
var mimetype = await getmime(file); var mimetype = await getmime(file);
}else{
var mimetype = forcemime;
}
var form_data = new formdata(); var form_data = new formdata();
form_data.append("text", text); form_data.append("text", text);
@ -816,7 +822,7 @@ deek.on("message", async function(msg, user){
break; break;
} }
var res = await fetch("https://4get.perennialte.ch/api/v1/videos?s=" + value); var res = await fetch("https://4get.perennialte.ch/api/v1/videos?s=" + encodeURIComponent(value));
var res_get = await res.json(); var res_get = await res.json();
if(res_get.status != "ok"){ if(res_get.status != "ok"){
@ -857,6 +863,48 @@ deek.on("message", async function(msg, user){
send(msg, "Search results for \"" + value + "\"\n\n" + text.join("\n\n")); send(msg, "Search results for \"" + value + "\"\n\n" + text.join("\n\n"));
break; break;
case "x":
case "xeno":
if(value.trim() == ""){
send(
msg,
"You must give me a search term you autistic cocksucker with no legs!!\nExample: .x owl"
);
break;
}
var res = await fetch("https://xeno-canto.org/api/2/recordings?query=" + encodeURIComponent(value));
var res_get = await res.json();
if(res_get.recordings.length === 0){
send(
msg,
"No recordings found for \"" + value + "\"!!!!!"
);
break;
}
var filereq = await fetch(
res_get.recordings[0].file,
{headers: img_headers}
);
var file = await filereq.buffer();
send(
msg,
">" + res_get.recordings[0].en + " in " + res_get.recordings[0].cnt + " (" + res_get.recordings[0].loc + ")\n" +
res_get.recordings[0].rmk,
file,
[
"audio/mpeg",
"mp3"
]
);
break;
case "help": case "help":
case "h": case "h":
send( send(
@ -868,6 +916,7 @@ deek.on("message", async function(msg, user){
".page/.p => get page offset for image search\n" + ".page/.p => get page offset for image search\n" +
".pp => get next page\n" + ".pp => get next page\n" +
".yt/.youtube => search the jewish propaganda catalog (now powered by 4get)\n" + ".yt/.youtube => search the jewish propaganda catalog (now powered by 4get)\n" +
".x/xeno => search for bird sounds\n" +
".roll/.r => Because deekchat was too slow\n" + ".roll/.r => Because deekchat was too slow\n" +
".mumble/.m <[optional]ip:port> => check if lolcat died\n" + ".mumble/.m <[optional]ip:port> => check if lolcat died\n" +
".prop => check if the sun has exploded or smth\n" + ".prop => check if the sun has exploded or smth\n" +