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/miku/plugins/get_txt.lua

26 lines
544 B
Lua
Raw Normal View History

local get_txt = {}
get_txt.triggers = {
"(https?://.*.txt)"
}
function get_txt:action(msg, config, matches)
local url = matches[1]
local doer = http
if url:match('^https') then
doer = https
end
local res, code = doer.request(url)
if code ~= 200 then
2016-08-24 17:18:17 +02:00
utilities.send_reply(msg, config.errors.connection)
return
end
if string.len(res) > 500 then
2016-09-21 22:43:15 +02:00
result = string.sub(res, 1, 500)..'...\n(Text gekürzt, da länger als 500 Zeichen.)'
else
result = res
end
utilities.send_reply(msg, result)
end
return get_txt