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/luarun.lua

36 lines
872 B
Lua
Raw Normal View History

local luarun = {}
local bindings = require('bindings')
local utilities = require('utilities')
function luarun:init()
luarun.triggers = utilities.triggers(self.info.username):t('lua', true).table
end
function luarun:action(msg)
if msg.from.id ~= self.config.admin then
return
end
local input = utilities.input(msg.text)
if not input then
bindings.sendReply(self, msg, 'Please enter a string to load.')
return
end
2016-04-29 06:36:35 +02:00
local output = loadstring('local bindings = require(\'bindings\'); local utilities = require(\'utilities\'); return function (self, msg) '..input..' end')()(self, msg)
if output == nil then
2015-12-14 20:48:17 +01:00
output = 'Done!'
elseif type(output) == 'table' then
output = 'Done! Table returned.'
2015-12-14 20:48:17 +01:00
else
output = '```\n' .. tostring(output) .. '\n```'
2015-12-14 20:48:17 +01:00
end
bindings.sendMessage(self, msg.chat.id, output, true, msg.message_id, true)
end
return luarun