Skip to content

Commit

Permalink
Adding .eth eur/usd
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyLemon committed Jan 1, 2018
1 parent 1bac7d5 commit 290a757
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
18 changes: 18 additions & 0 deletions scripts/servisi.coffee
Expand Up @@ -155,6 +155,24 @@ module.exports = (bot) ->
r.reply "Vrednost BTC v #{currency.toUpperCase()}: last: #{data.last}, low: #{data.low}, high: #{data.high}, bid: #{data.bid}, ask: #{data.ask}"
else
r.reply "Bitstamp is down"
else
r.reply "Nau šlo. Poskusi .btc eur ali .btc usd."

bot.regexp /^\.eth (.+)/,
".eth <valuta> - izpiše trenutno ETH vrednost na coinmarketcap.com",
(match,r) ->
currency = match[1].toLowerCase()
if currency == "eur" || currency == "usd"
bot.fetchJSON "https://api.coinmarketcap.com/v1/ticker/ethereum/?convert=EUR", (data) ->
if data && ! null
if currency == "eur"
r.reply "Vrednost #{data[0].name} v #{currency.toUpperCase()}: #{data[0].price_eur} (#{data[0].price_btc} BTC)"
else
r.reply "Vrednost #{data[0].name} v #{currency.toUpperCase()}: #{data[0].price_usd} (#{data[0].price_btc} BTC)"
else
r.reply "Coinmarketcap.com is down"
else
r.reply "Nau šlo. Poskusi .eth eur ali .eth usd"

bot.regexp /^\.xkcd\s?(.+)?/,
(match, r) ->
Expand Down
10 changes: 10 additions & 0 deletions test/servisi.coffee
Expand Up @@ -96,3 +96,13 @@ describe 'servisi.coffee', ->
expect(msg).to.be.a('string')
expect(msg).to.equal "Ne najdem"
done()

it 'test .eth eur', (done)->
bot.test ".eth eur", (msg) ->
expect(msg).to.be.a('string')
done()

it 'test .eth usd', (done)->
bot.test ".eth usd", (msg) ->
expect(msg).to.be.a('string')
done()

0 comments on commit 290a757

Please sign in to comment.