Merge Upstream
This commit is contained in:
commit
f4cf9c6d96
59
miku/plugins/luarun.lua
Normal file
59
miku/plugins/luarun.lua
Normal file
@ -0,0 +1,59 @@
|
||||
local luarun = {}
|
||||
|
||||
function luarun:init(config)
|
||||
luarun.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('lua', true):t('return', true).table
|
||||
if config.luarun_serpent then
|
||||
serpent = require('serpent')
|
||||
luarun.serialize = function(t)
|
||||
return serpent.block(t, {comment=false})
|
||||
end
|
||||
else
|
||||
JSON = require('dkjson')
|
||||
luarun.serialize = function(t)
|
||||
return JSON.encode(t, {indent=true})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function luarun:action(msg, config)
|
||||
|
||||
if not is_sudo(msg, config) then
|
||||
return true
|
||||
end
|
||||
|
||||
local input = utilities.input(msg.text)
|
||||
if not input then
|
||||
utilities.send_reply(msg, 'Bitte gebe einen Befehl ein.')
|
||||
return
|
||||
end
|
||||
|
||||
if msg.text_lower:match('^'..config.cmd_pat..'return') then
|
||||
input = 'return ' .. input
|
||||
end
|
||||
|
||||
local output = loadstring( [[
|
||||
local bot = require('miku.bot')
|
||||
local bindings = require('miku.bindings')
|
||||
local utilities = require('miku.utilities')
|
||||
local json = require('dkjson')
|
||||
local URL = require('socket.url')
|
||||
local http = require('socket.http')
|
||||
local https = require('ssl.https')
|
||||
return function (msg, config) ]] .. input .. [[ end
|
||||
]] )()(msg, config)
|
||||
if output == nil then
|
||||
output = 'Ausgeführt!'
|
||||
else
|
||||
if type(output) == 'table' then
|
||||
local s = luarun.serialize(output)
|
||||
if URL.escape(s):len() < 4000 then
|
||||
output = s
|
||||
end
|
||||
end
|
||||
output = '```\n' .. tostring(output) .. '\n```'
|
||||
end
|
||||
utilities.send_message(msg.chat.id, output, true, msg.message_id, true)
|
||||
|
||||
end
|
||||
|
||||
return luarun
|
@ -7,7 +7,8 @@ function quotes:init(config)
|
||||
"^/(delquote) (.+)$",
|
||||
"^/(addquote) (.+)$",
|
||||
"^/(quote)$",
|
||||
"^/(listquotes)$"
|
||||
"^/(listquotes)$",
|
||||
"^/(delquote)$"
|
||||
}
|
||||
quotes.doc = [[*
|
||||
]]..config.cmd_pat..[[addquote* _<Zitat>_: Fügt Zitat hinzu.
|
||||
@ -87,12 +88,27 @@ function quotes:action(msg, config, matches)
|
||||
utilities.send_reply(msg, quotes:save_quote(msg), true)
|
||||
return
|
||||
elseif matches[1] == "delquote" and matches[2] then
|
||||
<<<<<<< HEAD:miku/plugins/quotes.lua
|
||||
if msg.from.id ~= config.admin then
|
||||
utilities.send_reply(msg, config.errors.sudo, true)
|
||||
=======
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo)
|
||||
>>>>>>> upstream/master:otouto/plugins/quotes.lua
|
||||
return
|
||||
end
|
||||
utilities.send_reply(msg, quotes:delete_quote(msg), true)
|
||||
return
|
||||
elseif matches[1] == "delquote" and not matches[2] then
|
||||
if not is_sudo(msg, config) then
|
||||
utilities.send_reply(msg, config.errors.sudo)
|
||||
return
|
||||
end
|
||||
if msg.reply_to_message then
|
||||
local msg = msg.reply_to_message
|
||||
utilities.send_reply(msg, quotes:delete_quote(msg), true)
|
||||
return
|
||||
end
|
||||
elseif matches[1] == "listquotes" then
|
||||
local link, iserror = quotes:list_quotes(msg)
|
||||
if iserror then
|
||||
|
Reference in New Issue
Block a user