Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function quotation()
- local http = require("socket.http")
- local xml = require("xml")
- local parser = xml.Parser(xml.Parser.Fastest)
- http.TIMEOUT = 5
- r, c = http.request("http://developers.agenciaideias.com.br/cotacoes/xml")
- local data = parser:load(r)
- for k, v in pairs(data[2]) do
- if v[1] ~= nil then
- quotation = v[1]
- quotation = string.gsub(quotation, "%s+", "")
- break
- return "Quotation: R$ "..quotation
- end
- end
- for x, y in pairs(data) do
- if type(y[1]) ~= "table" then
- if type(y[1]) ~= nil then
- update = y[1]
- update = string.gsub(update, "%s+", "")
- update = string.gsub(update, "-", " ")
- break
- return "Updated: "..update
- end
- end
- end
- end
- function run(msg, matches)
- return quotation()
- end
- return {
- description = "Shows the dollar quotation",
- usage = "!quotation",
- patterns = {"^!quotation$"},
- run = run
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement