]>
jfr.im git - erebus.git/blob - modules/coins.py
1 # Erebus IRC bot - Author: Erebus Team
3 # This file is released into the public domain; see http://unlicense.org/
7 'author': 'Erebus Team',
8 'license': 'public domain',
9 'compatible': [1], # compatible module API versions
10 'depends': [], # other modules required to work properly?
15 lib
= modlib
.modlib(__name__
)
16 modstart
= lib
.modstart
23 url
= 'http://www.cryptocoincharts.info/v2/api/tradingPairs'
25 def get_coin_price(pairs
):
26 response
= requests
.post(url
, data
= {'pairs': pairs}
)
27 return json
.loads(response
.text
)
30 def cmd_gtest(bot
, user
, chan
, realtarget
, *args
):
33 response
= get_coin_price('btc_eur')
34 price
= str(float(response
[0]['price']) * float(args
[0]))
35 bot
.msg(chan
, "%s BTC = %s EUR" % (args
[0], price
))
37 bot
.msg(chan
, "Invalid amount.")
39 response
= get_coin_price('btc_eur')
40 price
= str(float(response
[0]['price']))
41 bot
.msg(chan
, "1 BTC = %s EUR" % price
)
44 def cmd_gtest(bot
, user
, chan
, realtarget
, *args
):
47 doge_btc
= get_coin_price('doge_btc')
48 btc_eur
= get_coin_price('btc_eur')
49 price
= str(float(doge_btc
[0]['price']) * float(btc_eur
[0]['price']) * float(args
[0]))
50 bot
.msg(chan
, "%s DOGE = %s EUR" % (args
[0], price
))
52 bot
.msg(chan
, "Invalid amount.")
54 doge_btc
= get_coin_price('doge_btc')
55 btc_eur
= get_coin_price('btc_eur')
56 price
= str(float(doge_btc
[0]['price']) * float(btc_eur
[0]['price']))
57 bot
.msg(chan
, "1 DOGE = %s EUR" % price
)
60 def cmd_gtest(bot
, user
, chan
, realtarget
, *args
):
63 ltc_btc
= get_coin_price('ltc_btc')
64 btc_eur
= get_coin_price('btc_eur')
65 price
= str(float(ltc_btc
[0]['price']) * float(btc_eur
[0]['price']) * float(args
[0]))
66 bot
.msg(chan
, "%s LTC = %s EUR" % (args
[0], price
))
68 bot
.msg(chan
, "Invalid amount.")
70 ltc_btc
= get_coin_price('ltc_btc')
71 btc_eur
= get_coin_price('btc_eur')
72 price
= str(float(ltc_btc
[0]['price']) * float(btc_eur
[0]['price']))
73 bot
.msg(chan
, "1 LTC = %s EUR" % price
)