lastfm
This commit is contained in:
parent
e4e89c3891
commit
bdc423a949
32
src/inc/trigger/lastfm.mjs
Normal file
32
src/inc/trigger/lastfm.mjs
Normal file
|
@ -0,0 +1,32 @@
|
|||
import rp from "request-promise";
|
||||
import { cfg } from "../../inc/cfg";
|
||||
|
||||
export default bot => {
|
||||
bot._trigger.set("lastfm", new bot.trigger({
|
||||
call: /^(\.|\/)np/i,
|
||||
/*help: {
|
||||
text: "",
|
||||
usage: "[b].np[/b] [i]<user>[/i]"
|
||||
},*/
|
||||
f: e => {
|
||||
const api = `http://ws.audioscrobbler.com/2.0/?method=user.getRecentTracks&limit=1&api_key=${cfg.main.lastfm.val.key}&format=json&user=`;
|
||||
const nick = e.args[0] || e.user.nick;
|
||||
rp(`${api}${nick}`, { json: true })
|
||||
.then(res => {
|
||||
if(res.error)
|
||||
return e.reply("User not found");
|
||||
res = res.recenttracks;
|
||||
const track = res.track[0];
|
||||
const info = {
|
||||
user: res["@attr"].user,
|
||||
track: `${track.artist["#text"]} - ${track.name}`,
|
||||
playing: track["@attr"] ? true : false
|
||||
};
|
||||
e.reply( `[b]${info.user}[/b] is listening to [b]${info.track}[/b]` );
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
}));
|
||||
};
|
|
@ -7,6 +7,7 @@ import debug from "./debug";
|
|||
import drugs from "./drugs";
|
||||
import help from "./help";
|
||||
import kernel from "./kernel";
|
||||
import lastfm from "./lastfm";
|
||||
import mcmaniac from "./mcmaniac";
|
||||
import parser from "./parser";
|
||||
import quotes from "./quotes";
|
||||
|
@ -19,7 +20,7 @@ import wttr from "./wttr";
|
|||
|
||||
export default [
|
||||
cfg, chatbot, coins, cookie, core, debug,
|
||||
drugs, help, kernel, mcmaniac,
|
||||
drugs, help, kernel, lastfm, mcmaniac,
|
||||
parser, quotes, rape, sandbox,
|
||||
urban, nxy, uwe, wttr
|
||||
];
|
Loading…
Reference in New Issue
Block a user