-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheur.lua
More file actions
33 lines (29 loc) · 744 Bytes
/
eur.lua
File metadata and controls
33 lines (29 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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)
if matches[1] == "!eur" then
return getEURUSD(nil)
end
return getEURUSD(matches[1])
end
return {
description = "EURUSD market value",
usage = "!eur [USD]",
patterns = {
"^!eur$",
"^!eur (%d+[%d%.]*)$",
},
run = run
}