get_txt funktioniert nun mit http und https

This commit is contained in:
Akamaru 2016-02-02 22:44:09 +01:00
parent a057e25f05
commit 7e5c5ec06c
1 changed files with 7 additions and 2 deletions

View File

@ -1,5 +1,9 @@
local function run(msg, matches) local function run(msg, matches)
local res,code = http.request(matches[1]..'.txt') if string.starts(msg.text, "https") then
res,code = https.request('https://'..matches[1]..'.txt')
else
res,code = http.request('http://'..matches[1]..'.txt')
end
if code ~= 200 then return nil end if code ~= 200 then return nil end
return res return res
end end
@ -8,6 +12,7 @@ end
return { return {
description = "", description = "",
usage = "", usage = "",
patterns = {"^https?://(.*).txt$"}, patterns = {"^https://(.*).txt$",
"^http://(.*).txt$"},
run = run run = run
} }