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/miku/plugins/shell.lua
Akamaru 440926765f Übernehme Änderungen von Brawl345/Brawlbot-v2
Verwende in einigen Plugins HTML, statt Markdown
2016-08-04 13:44:56 +02:00

31 lines
795 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