Compare commits

...

2 commits

Author SHA1 Message Date
Er2
7e26dfa38d add all valutes in rub 2022-02-16 10:49:40 +03:00
Er2
6add3f5e6b update eval, pattern escape function 2022-02-16 10:35:11 +03:00
3 changed files with 17 additions and 2 deletions

View file

@ -39,11 +39,13 @@ return {
api = owner and C.api or nil,
}
for k,v in pairs(env) do t[k] = v end
local e, err = load(C.api.unparseArgs(msg.args), 'eval', 't', t)
local e, err = load(C.api.unparseArgs(msg.args), 'eval', 'bt', t)
xpcall(function()
if err then error(err) end
e = tostring(e() or '...')
end, function(err) e = err end)
C.api:send(msg, s .. '\n' .. e)
s = s ..'\n'.. e
s = s:gsub(C.api.token:escp(), '<TOKEN>')
C.api:reply(msg, s)
end
}

View file

@ -36,6 +36,15 @@ function rub:course(wants)
wants = type(wants) == 'table' and wants or {}
local r, founds = {}, {}
if table.find(wants, 'HELP')
or table.find(wants, 'ALL')
then
for _, v in pairs(resp.Valute) do
table.insert(r, ('%d %s (%s) = %f Руб.'):format(v.Nominal, v.Name, v.CharCode, v.Value:gsub(',', '.')))
end
return r, resp.Date, wants
end
for i = 1, #resp.Valute do
local v = resp.Valute[i]
if table.find(wants, v.CharCode) then

View file

@ -21,6 +21,10 @@ function table.findV(t, w)
end
end
function string.escp(s)
return s:gsub('[%^%$%%%(%)%.%[%]%*%+%-%?]', '%%%0')
end
function dump(t, d)
if not tonumber(d) or d < 0 then d = 0 end
local c = ''