Skip to content
Permalink
Browse files

Added links to respective results

  • Loading branch information...
charkala committed Feb 17, 2019
1 parent 9ed61ef commit d59d57e36223181517574ae44451715b140badfe
Showing with 19 additions and 7 deletions.
  1. +19 −7 bot.js
26 bot.js
@@ -47,7 +47,9 @@ bot.command('latest', (ctx) => {
\`\`\`
Height: ${data.result.height}
Difficulty: ${data.result.difficulty}
\`\`\``
\`\`\`
[View in Block Explorer](https://microbitcoinorg.github.io/explorer/)`,
{ disable_web_page_preview: true }
)
}
})
@@ -65,7 +67,9 @@ bot.command('supply', (ctx) => {
\`\`\`
Circulating Supply: ${(data.result.supply / 10000).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")} MBC
Total / Max Supply: 210,000,000,000 MBC
\`\`\``
\`\`\`
[View in Block Explorer](https://microbitcoinorg.github.io/explorer/)`,
{ disable_web_page_preview: true }
)
}
})
@@ -86,7 +90,9 @@ bot.command('balance', (ctx) => {
\`\`\`
Confirmed: ${data.result.confirmed / 10000} MBC
Unconfirmed: ${data.result.unconfirmed / 10000} MBC
\`\`\``
\`\`\`
[View in Block Explorer](https://microbitcoinorg.github.io/explorer/#/address/${address[1]})`,
{ disable_web_page_preview: true }
)
}
})
@@ -104,7 +110,7 @@ bot.command('height', (ctx) => {
request(`${baseUrl}blockchain.block.header&params[]=${height[1]}`, (error, response, body) => {
if (error || (response && response.statusCode !== 200)) {
ctx.reply('There was a problem accessing the server. Please try again later.')
} else if (body && body.result) {
} else if (body && JSON.parse(body).result) {
request(`${baseUrl}blockchain.block.info&params[]=${JSON.parse(body).result.block_hash}`, (err, res, data) => {
if (error || (response && response.statusCode !== 200)) {
ctx.reply('There was a problem accessing the server. Please try again later.')
@@ -119,7 +125,9 @@ Transactions: ${reply.result.tx_count}
Confirmations: ${reply.result.confirmations}
Difficulty: ${reply.result.difficulty}
Nonce: ${reply.result.nonce}
\`\`\``
\`\`\`
[View in Block Explorer](https://microbitcoinorg.github.io/explorer/#/height/${height[1]})`,
{ disable_web_page_preview: true }
)
}
})
@@ -148,7 +156,9 @@ bot.command('tx', (ctx) => {
Height: ${data.result.height}
Block Time: ${moment(data.result.blocktime * 1000).format('MMMM Do YYYY, h:mm:ss a')}
Confirmations: ${data.result.confirmations}
\`\`\``
\`\`\`
[View in Block Explorer](https://microbitcoinorg.github.io/explorer/#/tx/${txid[1]})`,
{ disable_web_page_preview: true }
)
} else {
ctx.replyWithMarkdown('Transaction not found. Please check and try again.')
@@ -190,7 +200,9 @@ bot.command('cg', (ctx) => {
BTC: ${data.market_data.current_price.btc.toFixed(8)}
KRW: ${data.market_data.current_price.krw < 1 ? data.market_data.current_price.krw.toFixed(8) : data.market_data.current_price.krw.toFixed(2)}
24h Change: ${Number(data.market_data.price_change_percentage_24h).toFixed(2)}%
\`\`\``
\`\`\`
[View in CoinGecko](https://coingecko.com/en/coins/microbitcoin)`,
{ disable_web_page_preview: true }
)
} else {
ctx.reply('There was a problem connecting to CoinGecko.\nPlease try again later.')

0 comments on commit d59d57e

Please sign in to comment.
You can’t perform that action at this time.