local triggers = {
'^/admin[@'..bot.username..']*'
}
local commands = {
['run'] = function(cmd)
local cmd = cmd:input()
if not cmd then
return 'Please enter a command to run.'
end
return io.popen(cmd):read('*all')
end,
['lua'] = function(cmd)
local a = loadstring(cmd)()
if a then
return a
else
return 'Done!'
['reload'] = function(cmd)
bot_init()
return 'Bot reloaded!'
['halt'] = function(cmd)
is_started = false
return 'Stopping bot!'
['error'] = function(cmd)
error('Intentional test error.')
local action = function(msg)
if msg.from.id ~= config.admin then
return
local input = msg.text:input()
if not input then
local list = 'Specify a command: '
for k,v in pairs(commands) do
list = list .. k .. ', '
list = list:gsub(', $', '.')
sendReply(msg, list)
if string.match(get_word(input, 1), k) then
sendReply(msg, v(input))
sendReply(msg, 'Specify a command: run, reload, halt.')
return {
action = action,
triggers = triggers