mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 12:49:57 +00:00
Simple fixes on lastfm.js
This commit is contained in:
parent
4b1d1de779
commit
66dff8ceb3
@ -54,10 +54,9 @@ module.exports = (bot) => {
|
|||||||
const artistUrl = `https://www.last.fm/music/${encodeURIComponent(artistName)}`;
|
const artistUrl = `https://www.last.fm/music/${encodeURIComponent(artistName)}`;
|
||||||
const userUrl = `https://www.last.fm/user/${encodeURIComponent(lastfmUser)}`;
|
const userUrl = `https://www.last.fm/user/${encodeURIComponent(lastfmUser)}`;
|
||||||
|
|
||||||
// Requesting the number of plays of last song
|
|
||||||
let num_plays = '';
|
let num_plays = '';
|
||||||
try{
|
try {
|
||||||
const response_plays = await axios.get(scrobbler_url, {
|
const response_plays = await axios.get(scrobbler_url, {
|
||||||
params: {
|
params: {
|
||||||
method: 'track.getInfo',
|
method: 'track.getInfo',
|
||||||
api_key,
|
api_key,
|
||||||
@ -71,9 +70,12 @@ module.exports = (bot) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
num_plays = response_plays.data.track.userplaycount;
|
num_plays = response_plays.data.track.userplaycount;
|
||||||
}catch (err){
|
} catch (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
ctx.reply('Error!', {
|
const message = Strings.lastFmErr
|
||||||
|
.replace("{lastfmUser}", `[${lastfmUser}](${userUrl})`)
|
||||||
|
.replace("{err}", err);
|
||||||
|
ctx.reply(message, {
|
||||||
parse_mode: "Markdown",
|
parse_mode: "Markdown",
|
||||||
reply_to_message_id: ctx.message.message_id
|
reply_to_message_id: ctx.message.message_id
|
||||||
});
|
});
|
||||||
@ -84,8 +86,7 @@ module.exports = (bot) => {
|
|||||||
.replace("{nowPlaying}", nowPlaying)
|
.replace("{nowPlaying}", nowPlaying)
|
||||||
.replace("{trackName}", `[${trackName}](${trackUrl})`)
|
.replace("{trackName}", `[${trackName}](${trackUrl})`)
|
||||||
.replace("{artistName}", `[${artistName}](${artistUrl})`)
|
.replace("{artistName}", `[${artistName}](${artistUrl})`)
|
||||||
.replace("{plays}", `${num_plays}`)
|
.replace("{plays}", `${num_plays}`);
|
||||||
;
|
|
||||||
|
|
||||||
if (imageUrl) {
|
if (imageUrl) {
|
||||||
ctx.replyWithPhoto(imageUrl, {
|
ctx.replyWithPhoto(imageUrl, {
|
||||||
@ -99,7 +100,6 @@ module.exports = (bot) => {
|
|||||||
reply_to_message_id: ctx.message.message_id
|
reply_to_message_id: ctx.message.message_id
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const userUrl = `https://www.last.fm/user/${encodeURIComponent(lastfmUser)}`;
|
const userUrl = `https://www.last.fm/user/${encodeURIComponent(lastfmUser)}`;
|
||||||
const message = Strings.lastFmErr
|
const message = Strings.lastFmErr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user