This commit is contained in:
Er2 2021-07-27 11:15:28 +03:00
parent 2c660c0a09
commit 60c7c2c60b
4 changed files with 12 additions and 9 deletions

View file

@ -38,7 +38,7 @@ local function receiveUpdate(self, update)
and not to then return end
local args = {}
txt = msg.text:sub(#cmd + #(to or {}) + 3)
msg.text = msg.text:sub(#cmd + #(to or '') + 3)
for s in msg.text:gmatch '%S+' do table.insert(args, s) end
msg.cmd = cmd

View file

@ -44,7 +44,7 @@ return {
local v, d, f = rub:course(wants)
if v == 'error' then
return C.api:reply(msg, C.locale:get('error', 'req_err'))
return C.api:reply(msg, C.locale:get('error', 'req_err', msg.l))
end
local nf = {}

View file

@ -1,18 +1,21 @@
return function(C, api, msg)
local cmd = C.cmds[msg.cmd]
local owner = msg.from.id == C.config.owner
local l = msg.from.language_code
msg.l = l
if cmd == nil then
api:send(msg, C.locale:get('error', 'inv_cmd'))
api:send(msg, C.locale:get('error', 'inv_cmd', l))
elseif type(cmd.run) ~= 'function' then
api:send(msg, C.locale:get('error', 'cmd_run'))
api:send(msg, C.locale:get('error', 'cmd_run', l))
elseif cmd.private and not owner then
api:send(msg, C.locale:get('error', 'adm_cmd'))
api:send(msg, C.locale:get('error', 'adm_cmd', l))
else
msg.loc = C.locale:get('cmds', msg.cmd)
msg.loc = C.locale:get('cmds', msg.cmd, l)
local succ, err = pcall(cmd.run, C, msg, owner)
if not succ then
print(err)

View file

@ -14,10 +14,10 @@ function Locale:get(cat, k, lang)
assert(k, 'Give key')
lang = lang or self.main
local v = self[lang][cat][k]
local v = (self[lang] or {})[cat]
if not v then
return self[self.main][cat][k]
else return v end
return self[Locale.main][cat][k]
else return v[k] end
end
return function(C)