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.

36 lines
783 B
Lua
Raw Normal View History

local shell = {}
2016-06-07 00:31:34 -04:00
local utilities = require('otouto.utilities')
function shell:init(config)
2016-08-13 22:46:18 -04:00
shell.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('run', true).table
end
2016-05-26 17:26:30 -07:00
function shell:action(msg, config)
2016-08-13 22:46:18 -04:00
if msg.from.id ~= config.admin then
return
end
local input = utilities.input(msg.text)
input = input:gsub('', '--')
if not input then
utilities.send_reply(msg, 'Please specify a command to run.')
2016-08-13 22:46:18 -04:00
return
end
local f = io.popen(input)
local output = f:read('*all')
f:close()
if output:len() == 0 then
output = 'Done!'
else
output = '```\n' .. output .. '\n```'
end
utilities.send_message(msg.chat.id, output, true, msg.message_id, true)
end
return shell