Commit 24926372 authored by Cool Fire's avatar Cool Fire

Move dogecoin plugin away from discontinued API

parent f5cd78d9
Pipeline #561 passed with stages
in 3 minutes and 29 seconds
......@@ -14,37 +14,31 @@ class Dogecoin
@irc = irc
@timer = timer
@api_host = 'pubapi.cryptsy.com'
@api_path = '/api.php?method=singlemarketdata&marketid=132'
@last = BigDecimal.new( "0.0" )
@api_uri = 'https://api.cryptonator.com/api/ticker/doge-btc'
@last = BigDecimal( "0.0" )
end
# Alias for last
def main( _nick, _user, _host, from, _msg, _arguments, con )
uri = URI.parse( "http://#{@api_host}#{@api_path}" )
http = Net::HTTP.new( uri.host, uri.port )
request = Net::HTTP::Get.new( uri.request_uri )
response = http.request( request )
result = JSON.parse( response.body )
uri = URI(@api_uri)
response = Net::HTTP.get( uri )
puts response
result = JSON.parse( response )
# Calculate delta from last !btc
ldiff = BigDecimal.new( result[ 'return' ][ 'markets' ][ 'DOGE' ][ 'lasttradeprice' ] ) - @last
puts result.inspect
# Calculate delta from last !doge
ldiff = BigDecimal( result[ 'ticker' ][ 'price' ] ) - @last
if( ldiff > 0 )
ldiff = "+#{ldiff}"
else
ldiff = "#{ldiff}"
end
@last = BigDecimal.new( result[ 'return' ][ 'markets' ][ 'DOGE' ][ 'lasttradeprice' ] )
@last = BigDecimal( result[ 'ticker' ][ 'price' ] )
rounded = "#{( BigDecimal.new( result[ 'return' ][ 'markets' ][ 'DOGE' ][ 'lasttradeprice' ] ) * 100 ).round / 100.0}"
rounded = "#{( BigDecimal( result[ 'ticker' ][ 'price' ] ) * 100 ).round / 100.0}"
line = "Cryptsy DOGE/BTC rate: #{rounded} (#{result[ 'return' ][ 'markets' ][ 'DOGE' ][ 'lasttradeprice' ]}) (#{ldiff} since last !doge)"
line = "Cryptonator DOGE/BTC rate: #{rounded} (#{result[ 'ticker' ][ 'price' ]}) (#{ldiff} since last !doge)"
if( con )
@output.c( line + "\n" )
......@@ -56,10 +50,10 @@ class Dogecoin
# Function to send help about this plugin (Can also be called by the help plugin.)
def help( nick, _user, _host, _from, _msg, _arguments, con )
help = [
"Gets current litecoin values from Btc-e",
"Gets current litecoin values from cryptonator",
" dogecoin - Get DOGE/BTC exchange rate"
]
# Print out help
help.each do |line|
if( con )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment