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/plugins/admin.lua

48 lines
839 B
Lua
Raw Normal View History

2015-07-03 00:15:52 +02:00
local PLUGIN = {}
PLUGIN.triggers = {
2015-07-08 09:38:04 +02:00
'^/admin '
2015-07-03 00:15:52 +02:00
}
PLUGIN.no_typing = true
2015-07-03 00:15:52 +02:00
function PLUGIN.action(msg)
if msg.date < os.time() - 1 then return end
2015-07-03 00:15:52 +02:00
local input = get_input(msg.text)
local message = config.locale.errors.argument
2015-07-03 00:15:52 +02:00
if not config.admins[msg.from.id] then
return send_msg(msg, 'Permission denied.')
2015-07-08 04:24:12 +02:00
end
if string.lower(first_word(input)) == 'run' then
2015-07-03 00:15:52 +02:00
local output = get_input(input)
if not output then
return send_msg(msg, config.locale.errors.argument)
end
2015-07-03 00:15:52 +02:00
local output = io.popen(output)
message = output:read('*all')
output:close()
elseif string.lower(first_word(input)) == 'reload' then
bot_init()
message = 'Bot reloaded!'
elseif string.lower(first_word(input)) == 'halt' then
is_started = false
message = 'Shutting down...'
end
send_msg(msg, message)
end
return PLUGIN