mirror of
https://github.com/LBRYFoundation/lbry-wunderbot.git
synced 2025-09-16 15:29:44 +00:00
Merge pull request #81 from MSFTserver/patch-4
fix hash bot when WTM api is down[done]
This commit is contained in:
commit
8baaae7cb5
1 changed files with 123 additions and 131 deletions
|
@ -20,8 +20,7 @@ exports.timedhash = function(bot) {
|
||||||
needle.get('https://explorer.lbry.io/api/v1/status', function(error, response) {
|
needle.get('https://explorer.lbry.io/api/v1/status', function(error, response) {
|
||||||
if (error || response.statusCode !== 200) {
|
if (error || response.statusCode !== 200) {
|
||||||
msg.channel.send('Explorer API is not available');
|
msg.channel.send('Explorer API is not available');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
var data = response.body;
|
var data = response.body;
|
||||||
var height = Number(data.status.height);
|
var height = Number(data.status.height);
|
||||||
var hashrate = data.status.hashrate;
|
var hashrate = data.status.hashrate;
|
||||||
|
@ -29,7 +28,7 @@ needle.get('https://explorer.lbry.io/api/v1/status', function(error, response) {
|
||||||
needle.get('https://whattomine.com/coins/164.json', function(error, response) {
|
needle.get('https://whattomine.com/coins/164.json', function(error, response) {
|
||||||
if (error || response.statusCode !== 200) {
|
if (error || response.statusCode !== 200) {
|
||||||
msg.channel.send('whattomine API is not available');
|
msg.channel.send('whattomine API is not available');
|
||||||
} else {
|
}
|
||||||
var data = response.body;
|
var data = response.body;
|
||||||
var reward = Number(data.block_reward);
|
var reward = Number(data.block_reward);
|
||||||
var block_time = Number(data.block_time);
|
var block_time = Number(data.block_time);
|
||||||
|
@ -52,7 +51,6 @@ needle.get('https://explorer.lbry.io/api/v1/status', function(error, response) {
|
||||||
};
|
};
|
||||||
bot.channels.get(ChannelID).send({ embed })
|
bot.channels.get(ChannelID).send({ embed })
|
||||||
return
|
return
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -80,7 +78,6 @@ exports.hash = {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function sendMiningInfo(bot, msg, suffix) {
|
function sendMiningInfo(bot, msg, suffix) {
|
||||||
if(!inPrivate(msg) && !hasHashBotChannels(msg)){
|
if(!inPrivate(msg) && !hasHashBotChannels(msg)){
|
||||||
msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to hash bot.');
|
msg.channel.send('Please use <#' + ChannelID + '> or DMs to talk to hash bot.');
|
||||||
|
@ -89,8 +86,7 @@ function sendMiningInfo(bot, msg, suffix) {
|
||||||
needle.get('https://explorer.lbry.io/api/v1/status', function(error, response) {
|
needle.get('https://explorer.lbry.io/api/v1/status', function(error, response) {
|
||||||
if (error || response.statusCode !== 200) {
|
if (error || response.statusCode !== 200) {
|
||||||
msg.channel.send('Explorer API is not available');
|
msg.channel.send('Explorer API is not available');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
var data = response.body;
|
var data = response.body;
|
||||||
var height = Number(data.status.height);
|
var height = Number(data.status.height);
|
||||||
var hashrate = data.status.hashrate;
|
var hashrate = data.status.hashrate;
|
||||||
|
@ -98,7 +94,7 @@ function sendMiningInfo(bot, msg, suffix) {
|
||||||
needle.get('https://whattomine.com/coins/164.json', function(error, response) {
|
needle.get('https://whattomine.com/coins/164.json', function(error, response) {
|
||||||
if (error || response.statusCode !== 200) {
|
if (error || response.statusCode !== 200) {
|
||||||
msg.channel.send('whattomine API is not available');
|
msg.channel.send('whattomine API is not available');
|
||||||
} else {
|
}
|
||||||
var data = response.body;
|
var data = response.body;
|
||||||
var reward = Number(data.block_reward);
|
var reward = Number(data.block_reward);
|
||||||
var block_time = Number(data.block_time);
|
var block_time = Number(data.block_time);
|
||||||
|
@ -121,7 +117,6 @@ function sendMiningInfo(bot, msg, suffix) {
|
||||||
};
|
};
|
||||||
msg.channel.send({ embed });
|
msg.channel.send({ embed });
|
||||||
return
|
return
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -165,8 +160,5 @@ function sendProfitInfo(bot, msg, suffix) {
|
||||||
function numberWithCommas(x) {
|
function numberWithCommas(x) {
|
||||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue