acc7046d64
Added optional target for kick/ban logs. Added flag 7 to use default log per group. This way, a realm can have a public kick/ban log but governors are able to opt out. Added flag 8, antilink. Kicks for Telegram join links which do not refer to groups within the realm. Added flag 9, modrights, to give moderators access to changing the group photo, title, link, and motd (config option is deprecated. RIP). /unban will reset the target's autokick counter. Added configuration for default flag settings. Revision to bindings.lua. BASE_URL has been moved to bindings. There is no real reason for it to remain in instance. Token is passed to bindings.init at load. All plugins have been updated accordingly.
76 lines
2.1 KiB
Lua
76 lines
2.1 KiB
Lua
local luarun = {}
|
|
|
|
local utilities = require('otouto.utilities')
|
|
local URL = require('socket.url')
|
|
local JSON, serpent
|
|
|
|
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 msg.from.id ~= config.admin then
|
|
return true
|
|
end
|
|
|
|
local input = utilities.input(msg.text)
|
|
if not input then
|
|
utilities.send_reply(msg, 'Please enter a string to load.')
|
|
return
|
|
end
|
|
|
|
if msg.text_lower:match('^'..config.cmd_pat..'return') then
|
|
input = 'return ' .. input
|
|
end
|
|
|
|
local output, success =
|
|
loadstring("local bot = require('otouto.bot')\n\z
|
|
local bindings = require('otouto.bindings')\n\z
|
|
local utilities = require('otouto.utilities')\n\z
|
|
local drua = require('otouto.drua-tg')\n\z
|
|
local JSON = require('dkjson')\n\z
|
|
local URL = require('socket.url')\n\z
|
|
local HTTP = require('socket.http')\n\z
|
|
local HTTPS = require('ssl.https')\n\z
|
|
return function (self, msg, config)\n" .. input .. "\nend")
|
|
|
|
local function err_msg(x)
|
|
return "Error:\n" .. tostring(x)
|
|
end
|
|
|
|
if output == nil then
|
|
output = success
|
|
else
|
|
success, output = xpcall(output(), err_msg, self, msg, config)
|
|
end
|
|
|
|
if output == nil then
|
|
output = 'Done!'
|
|
else
|
|
if type(output) == 'table' then
|
|
local s = luarun.serialize(output)
|
|
if URL.escape(s):len() < 4000 then
|
|
output = s
|
|
end
|
|
end
|
|
output = '<code>' .. utilities.html_escape(tostring(output)) .. '</code>'
|
|
end
|
|
utilities.send_message(msg.chat.id, output, true, msg.message_id, 'html')
|
|
|
|
end
|
|
|
|
return luarun
|
|
|