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.
2015-08-19 15:14:30 +02:00
|
|
|
local function run(msg, patterns)
|
|
|
|
local response_body = {}
|
|
|
|
local request_constructor = {
|
|
|
|
url = patterns[1],
|
|
|
|
method = "HEAD",
|
|
|
|
sink = ltn12.sink.table(response_body),
|
|
|
|
headers = {},
|
|
|
|
redirect = false
|
|
|
|
}
|
|
|
|
|
|
|
|
local ok, response_code, response_headers, response_status_line = http.request(request_constructor)
|
|
|
|
if ok and response_headers.location then
|
|
|
|
return response_headers.location
|
|
|
|
else
|
|
|
|
return "Fehler beim Erweitern der URL."
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
|
|
|
description = "Erweitert eine verkürzte URL",
|
2016-06-22 13:59:06 +02:00
|
|
|
usage = "#expand [URL]: Erweitert einen verkürzten Link",
|
2015-08-19 15:14:30 +02:00
|
|
|
patterns = {
|
2016-06-22 13:59:06 +02:00
|
|
|
"^#expand (https?://[%w-_%.%?%.:/%+=&]+)$"
|
2015-08-19 15:14:30 +02:00
|
|
|
},
|
|
|
|
run = run
|
|
|
|
}
|