blob: 77b98dca4d28fb4f5a6f27e496c61ca5e936bc08 [file] [log] [blame]
Serge Bazanski18c1a262022-07-07 14:24:53 +02001local socket = require("socket")
2local http = require("socket.http")
3local json = require("vendor.json")
4local lume = require("vendor.lume")
5
6local btcURL = 'http://www.bitmarket.pl/json/BTCPLN/ticker.json'
7local tryURL = 'http://api.fixer.io/latest?base=TRY'
8
9local r, c, h = http.request(btcURL)
10if c == 200 then
11 btcpln = json.decode(r)['last']
12 local r, c, h = http.request(tryURL)
13 if c == 200 then
14 tryidr = json.decode(r)['rates']['IDR']
15 end
16 love.thread.getChannel('currency'):push({
17 values = {math.floor(btcpln), math.floor(tryidr)},
18 })
19 print("Update finished")
20else
21 print("Update failed")
22end