Merge Upstream

This commit is contained in:
Akamaru 2016-08-26 18:05:21 +02:00
commit f4cf9c6d96
3 changed files with 110 additions and 35 deletions

View File

@ -1,35 +1,35 @@
language: erlang language: erlang
before_install: before_install:
- CURDIR=$(pwd) - CURDIR=$(pwd)
- sudo apt-get update -qq - sudo apt-get update -qq
- sudo apt-get install -qq libreadline-dev libconfig-dev libssl-dev lua5.2 liblua5.2-dev libevent-dev make unzip git libjansson-dev - sudo apt-get install -qq libreadline-dev libconfig-dev libssl-dev lua5.2 liblua5.2-dev libevent-dev make unzip git libjansson-dev
- THIS_DIR=$(cd $(dirname $0); pwd) - THIS_DIR=$(cd $(dirname $0); pwd)
- cd $THIS_DIR - cd $THIS_DIR
- git clone https://github.com/keplerproject/luarocks.git - git clone https://github.com/keplerproject/luarocks.git
- cd luarocks - cd luarocks
- git checkout tags/v2.3.0 - git checkout tags/v2.3.0
- PREFIX="$THIS_DIR/.luarocks" - PREFIX="$THIS_DIR/.luarocks"
- ./configure --prefix=$PREFIX --sysconfdir=$PREFIX/luarocks --force-config - ./configure --prefix=$PREFIX --sysconfdir=$PREFIX/luarocks --force-config
- make build && make install - make build && make install
- cd .. - cd ..
- rm -rf luarocks - rm -rf luarocks
- ./.luarocks/bin/luarocks install luasocket - ./.luarocks/bin/luarocks install luasocket
- ./.luarocks/bin/luarocks install luasec - ./.luarocks/bin/luarocks install luasec
- ./.luarocks/bin/luarocks install multipart-post - ./.luarocks/bin/luarocks install multipart-post
- ./.luarocks/bin/luarocks install dkjson - ./.luarocks/bin/luarocks install dkjson
- ./.luarocks/bin/luarocks install oauth - ./.luarocks/bin/luarocks install oauth
- ./.luarocks/bin/luarocks install redis-lua - ./.luarocks/bin/luarocks install redis-lua
- ./.luarocks/bin/luarocks install lua-cjson - ./.luarocks/bin/luarocks install lua-cjson
- ./.luarocks/bin/luarocks install fakeredis - ./.luarocks/bin/luarocks install fakeredis
- ./.luarocks/bin/luarocks install xml - ./.luarocks/bin/luarocks install xml
- ./.luarocks/bin/luarocks install feedparser - ./.luarocks/bin/luarocks install feedparser
- ./.luarocks/bin/luarocks install serpent - ./.luarocks/bin/luarocks install serpent
- ./.luarocks/bin/luarocks install sha1 - ./.luarocks/bin/luarocks install sha1
- ./.luarocks/bin/luarocks install lpeg - ./.luarocks/bin/luarocks install lpeg
- cd $CURDIR - cd $CURDIR
script: script:
- luac -p miku/*.lua - luac -p miku/*.lua
- luac -p miku/plugins/*.lua - luac -p miku/plugins/*.lua

59
miku/plugins/luarun.lua Normal file
View 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

View File

@ -7,7 +7,8 @@ function quotes:init(config)
"^/(delquote) (.+)$", "^/(delquote) (.+)$",
"^/(addquote) (.+)$", "^/(addquote) (.+)$",
"^/(quote)$", "^/(quote)$",
"^/(listquotes)$" "^/(listquotes)$",
"^/(delquote)$"
} }
quotes.doc = [[* quotes.doc = [[*
]]..config.cmd_pat..[[addquote* _<Zitat>_: Fügt Zitat hinzu. ]]..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) utilities.send_reply(msg, quotes:save_quote(msg), true)
return return
elseif matches[1] == "delquote" and matches[2] then elseif matches[1] == "delquote" and matches[2] then
<<<<<<< HEAD:miku/plugins/quotes.lua
if msg.from.id ~= config.admin then if msg.from.id ~= config.admin then
utilities.send_reply(msg, config.errors.sudo, true) 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 return
end 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) utilities.send_reply(msg, quotes:delete_quote(msg), true)
return return
end
elseif matches[1] == "listquotes" then elseif matches[1] == "listquotes" then
local link, iserror = quotes:list_quotes(msg) local link, iserror = quotes:list_quotes(msg)
if iserror then if iserror then