2021-04-14 06:03:25 +00:00
|
|
|
|
return function(C, api, msg)
|
|
|
|
|
local cmd = C.cmds[msg.cmd]
|
2021-04-17 09:20:00 +00:00
|
|
|
|
local owner = msg.from.id == C.config.owner
|
2021-04-14 06:03:25 +00:00
|
|
|
|
if cmd == nil then
|
|
|
|
|
api:send(msg, 'Invaid command provided.')
|
|
|
|
|
|
|
|
|
|
elseif type(cmd.run) ~= 'function' then
|
|
|
|
|
api:send(msg, 'Command cannot be executed.')
|
|
|
|
|
|
|
|
|
|
elseif cmd.private and not owner then
|
|
|
|
|
api:send(msg, 'You can\'t execute private commands!')
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
local succ, err = pcall(cmd.run, C, msg, owner)
|
|
|
|
|
if not succ then
|
|
|
|
|
api:reply(msg, 'Произошла ошибочка, которая была отправлена создателю')
|
2021-04-17 09:20:00 +00:00
|
|
|
|
print(err)
|
|
|
|
|
local cid = C.config.owner
|
2021-04-14 06:03:25 +00:00
|
|
|
|
api:forward(cid, msg.chat.id, msg.message_id, false)
|
|
|
|
|
api:send(cid, err)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|