Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Bitstamp API #67

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis/deploy.sh
Expand Up @@ -7,4 +7,4 @@ chmod 600 .travis/deploy_key.pem # this key should have push access
ssh-add .travis/deploy_key.pem
rm -rf .travis/deploy_key.pem
git remote add dokku dokku@$APP_HOSTNAME:$APP
git push --force dokku HEAD:master
git push --force dokku HEAD:master
1 change: 1 addition & 0 deletions Readme.md
Expand Up @@ -29,6 +29,7 @@ Pomoč:
.ac <?> -- for what
.apt <paket> -- Najde pakete po imenu v packages.ubuntu.com
.asku <pojem> -- Išči po askubuntu, če vsebuje !! potem prikaže povezave
.btc <valuta> - Izpiše trenutno BTC vrednost na Bitstamp (na voljo USD, EUR)
.ddg -- Vse kar zna https://api.duckduckgo.com/api ali https://api.duckduckgo.com/goodies
.imdb <naslov> -- Dobi osnovne podatke z IMBD
.morje -- Izpiše temperature slovenskega morja (Koper, Debeli rtič ter Piran)
Expand Down
15 changes: 14 additions & 1 deletion scripts/servisi.coffee
Expand Up @@ -167,4 +167,17 @@ module.exports = (bot) ->
if data
irc.reply "Trenutno se predvaja: #{data.response.BroadcastMonitor.Current.artistName} - #{data.response.BroadcastMonitor.Current.titleName}"
else
irc.reply "OMG val202 is down!"
irc.reply "OMG val202 is down!"

bot.regexp /^\.btc (.+)/,
".btc <valuta> - izpiše trenutno BTC vrednost na Bitstamp",
(match, r) ->
currency = match[1].toLowerCase()
if currency == "eur" || currency == "usd"
bot.fetchJSON "https://www.bitstamp.net/api/v2/ticker/btc#{currency}/", (data) ->
if data && ! null
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 "Napačna valuta"
13 changes: 12 additions & 1 deletion test/servisi.coffee
Expand Up @@ -87,7 +87,18 @@ describe 'servisi.coffee', ->
bot.test ".time ljubljana", (msg) ->
expect(msg).to.be.a('string')
done()

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

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

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