gsub and 404

This commit is contained in:
Akamaru 2015-08-19 15:15:53 +02:00
parent 99afa43f50
commit 6c2d953c93
2 changed files with 2 additions and 26 deletions

View File

@ -1,26 +0,0 @@
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 "Can't expand the url."
end
end
return {
description = "Expand a shortened URL to the original one.",
usage = "!expand [url]: Return the original URL",
patterns = {
"^!expand (https?://[%w-_%.%?%.:/%+=&]+)$"
},
run = run
}

View File

@ -15,6 +15,7 @@ function getTitle(page)
s = string.gsub(s, ">", ">")
s = string.gsub(s, "&", "&")
s = string.gsub(s, "'", "'")
s = string.gsub(s, "’", "'")
s = string.gsub(s, "–", "")
s = string.gsub(s, "»", "»")
s = string.gsub(s, "–", "")
@ -64,6 +65,7 @@ function run(msg, matches)
title == "Moved Permanently" or
title == "Redirection" or
title == "Object moved" or
title == "Error 404 (Not Found)!!1" or
string.match(title, "on Steam") or
string.match(title, "521: Web server is down") or
string.match(title, "eBay</title>") or