23 lines
622 B
Lua
23 lines
622 B
Lua
|
local socket = require("socket")
|
||
|
local http = require("socket.http")
|
||
|
local json = require("vendor.json")
|
||
|
local lume = require("vendor.lume")
|
||
|
|
||
|
local btcURL = 'http://www.bitmarket.pl/json/BTCPLN/ticker.json'
|
||
|
local tryURL = 'http://api.fixer.io/latest?base=TRY'
|
||
|
|
||
|
local r, c, h = http.request(btcURL)
|
||
|
if c == 200 then
|
||
|
btcpln = json.decode(r)['last']
|
||
|
local r, c, h = http.request(tryURL)
|
||
|
if c == 200 then
|
||
|
tryidr = json.decode(r)['rates']['IDR']
|
||
|
end
|
||
|
love.thread.getChannel('currency'):push({
|
||
|
values = {math.floor(btcpln), math.floor(tryidr)},
|
||
|
})
|
||
|
print("Update finished")
|
||
|
else
|
||
|
print("Update failed")
|
||
|
end
|