This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot-2/otouto/plugins/shell.lua
2016-08-04 13:02:47 +02:00

32 lines
796 B
Lua

local shell = {}
function shell:init(config)
shell.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('sh', true).table
end
function shell:action(msg, config)
if not is_sudo(msg, config) then
utilities.send_reply(self, msg, config.errors.sudo)
return
end
local input = utilities.input(msg.text)
if not input then
utilities.send_reply(self, msg, 'Bitte gib ein Kommando ein.')
return
end
input = input:gsub('', '--')
local output = run_command(input)
if output:len() == 0 then
output = 'Ausgeführt.'
else
output = '<pre>\n' .. output .. '\n</pre>'
end
output = output:gsub('<pre>%\n', '<pre>')
output = output:gsub('%\n%\n</pre>', '</pre>')
utilities.send_message(self, msg.chat.id, output, true, msg.message_id, 'HTML')
end
return shell