This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot/plugins/eur.lua
2014-11-04 22:06:59 +01:00

28 lines
653 B
Lua

function getEURUSD(usd)
b = http.request("http://webrates.truefx.com/rates/connect.html?c=EUR/USD&f=csv&s=n")
local rates = b:split(", ")
local symbol = rates[1]
local timestamp = rates[2]
local sell = rates[3]..rates[4]
local buy = rates[5]..rates[6]
text = symbol..'\n'..'Buy: '..buy..'\n'..'Sell: '..sell
if usd then
eur = tonumber(usd) / tonumber(buy)
text = text.."\n "..usd.."USD = "..eur.."EUR"
end
return text
end
function run(msg, matches)
return getEURUSD(matches[1])
end
return {
description = "EURUSD market value",
usage = "!eur [USD]",
patterns = {"^!eur (%d+[%d%.]*)$"},
run = run
}