2015-04-14 20:21:23 +02:00
|
|
|
|
do
|
|
|
|
|
|
|
|
|
|
function getTitle(page)
|
|
|
|
|
local s = page
|
|
|
|
|
|
|
|
|
|
-- Remove optional spaces from the tags.
|
|
|
|
|
s = string.gsub(s, "\n", " ")
|
|
|
|
|
s = string.gsub(s, " *< *", "<")
|
|
|
|
|
s = string.gsub(s, " *> *", ">")
|
2015-08-12 18:19:55 +02:00
|
|
|
|
|
|
|
|
|
-- Character encoding
|
2015-11-12 17:42:03 +01:00
|
|
|
|
s = string.gsub(s, "´", "´")
|
2015-12-20 20:44:00 +01:00
|
|
|
|
s = string.gsub(s, "•", "•")
|
2015-06-11 17:10:03 +02:00
|
|
|
|
s = string.gsub(s, ">", ">")
|
2015-11-12 17:42:03 +01:00
|
|
|
|
s = string.gsub(s, """, '"')
|
|
|
|
|
s = string.gsub(s, "<", "<")
|
|
|
|
|
s = string.gsub(s, "—", "—")
|
|
|
|
|
s = string.gsub(s, "∇", "∇")
|
2015-06-17 20:26:37 +02:00
|
|
|
|
s = string.gsub(s, "–", "–")
|
2015-11-12 17:42:03 +01:00
|
|
|
|
s = string.gsub(s, "Ψ", "ψ")
|
|
|
|
|
s = string.gsub(s, "ψ", "ψ")
|
2015-06-25 22:08:20 +02:00
|
|
|
|
s = string.gsub(s, "»", "»")
|
2015-11-27 22:11:32 +01:00
|
|
|
|
s = string.gsub(s, "®", "®")
|
2015-11-18 17:08:15 +01:00
|
|
|
|
s = string.gsub(s, "ß", "ß")
|
2015-11-21 19:23:59 +01:00
|
|
|
|
s = string.gsub(s, "™", "™")
|
2015-12-17 17:54:04 +01:00
|
|
|
|
s = string.gsub(s, "&", "&")
|
2015-11-21 19:23:59 +01:00
|
|
|
|
s = string.gsub(s, "'", "'")
|
2015-11-12 17:42:03 +01:00
|
|
|
|
s = string.gsub(s, "'", "'")
|
|
|
|
|
s = string.gsub(s, "|", "|")
|
|
|
|
|
s = string.gsub(s, " ", " ")
|
2015-12-05 21:37:31 +01:00
|
|
|
|
s = string.gsub(s, "®", "®")
|
2015-09-08 22:23:48 +02:00
|
|
|
|
s = string.gsub(s, "»", "»")
|
2015-11-12 17:42:03 +01:00
|
|
|
|
s = string.gsub(s, "ß", "ß")
|
2015-07-31 18:01:10 +02:00
|
|
|
|
s = string.gsub(s, "–", "–")
|
2015-11-12 17:42:03 +01:00
|
|
|
|
s = string.gsub(s, "’", "'")
|
2015-07-02 14:09:56 +02:00
|
|
|
|
s = string.gsub(s, "“", "“")
|
|
|
|
|
s = string.gsub(s, "”", "”")
|
2015-11-22 20:52:17 +01:00
|
|
|
|
s = string.gsub(s, "„", "„")
|
2015-11-12 17:42:03 +01:00
|
|
|
|
s = string.gsub(s, "‹", "‹")
|
2015-08-12 18:19:55 +02:00
|
|
|
|
s = string.gsub(s, "€", "€")
|
|
|
|
|
|
|
|
|
|
-- Ä Ö Ü
|
2015-07-20 23:03:03 +02:00
|
|
|
|
s = string.gsub(s, "ä", "ä")
|
|
|
|
|
s = string.gsub(s, "Ä", "Ä")
|
2015-08-12 18:19:55 +02:00
|
|
|
|
s = string.gsub(s, "ä", "ä")
|
|
|
|
|
s = string.gsub(s, "Ä", "Ä")
|
2015-07-20 23:03:03 +02:00
|
|
|
|
s = string.gsub(s, "ö", "ö")
|
|
|
|
|
s = string.gsub(s, "Ö", "Ö")
|
2015-08-12 18:19:55 +02:00
|
|
|
|
s = string.gsub(s, "ö", "ö")
|
|
|
|
|
s = string.gsub(s, "Ö", "Ö")
|
2015-07-20 23:03:03 +02:00
|
|
|
|
s = string.gsub(s, "ü", "ü")
|
|
|
|
|
s = string.gsub(s, "Ü", "Ü")
|
2015-08-12 18:19:55 +02:00
|
|
|
|
s = string.gsub(s, "ü", "ü")
|
|
|
|
|
s = string.gsub(s, "Ü", "Ü")
|
2015-04-14 20:21:23 +02:00
|
|
|
|
|
|
|
|
|
-- Put all the tags in lowercase.
|
|
|
|
|
s = string.gsub(s, "(<[^ >]+)", string.lower)
|
2015-11-12 17:42:03 +01:00
|
|
|
|
s = string.gsub(s, "&", "&") -- Be sure to do this after all others
|
2015-04-14 20:21:23 +02:00
|
|
|
|
local i, f, t = string.find(s, "<title>(.+)</title>")
|
|
|
|
|
return t or ""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function string.ends(str, fin)
|
|
|
|
|
return fin=='' or string.sub(str,-string.len(fin)) == fin
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function run(msg, matches)
|
|
|
|
|
local url = matches[1]
|
|
|
|
|
local result = http.request(url)
|
|
|
|
|
local title = getTitle(result)
|
|
|
|
|
|
2015-04-20 18:52:25 +02:00
|
|
|
|
--Ignoring 301, 302, 404 and more
|
2015-04-28 17:49:11 +02:00
|
|
|
|
if title == "301 Moved Permanently" or
|
2015-04-20 18:52:25 +02:00
|
|
|
|
title == "" or
|
|
|
|
|
title == "404 Not Found" or
|
|
|
|
|
title == "302 Found" or
|
2015-04-22 16:49:24 +02:00
|
|
|
|
title == "302 Moved" or
|
2015-04-20 18:52:25 +02:00
|
|
|
|
title == "Moved Permanently" or
|
2015-04-23 17:29:03 +02:00
|
|
|
|
title == "Redirection" or
|
2015-04-29 21:32:17 +02:00
|
|
|
|
title == "Object moved" or
|
2015-08-19 15:15:53 +02:00
|
|
|
|
title == "Error 404 (Not Found)!!1" or
|
2015-12-17 17:54:04 +01:00
|
|
|
|
title == "Moved Temporarily" or
|
|
|
|
|
title == "Not Found" or
|
|
|
|
|
title == "Document Moved" or
|
|
|
|
|
title == "521: Web server is down" or
|
2015-05-07 19:49:26 +02:00
|
|
|
|
string.match(title, "on Steam") or
|
2015-04-21 15:59:09 +02:00
|
|
|
|
string.match(title, "eBay</title>") or
|
2015-05-10 13:09:06 +02:00
|
|
|
|
string.match(msg.text, "twitch.tv") or
|
2015-09-07 18:13:10 +02:00
|
|
|
|
string.match(msg.text, "twitter.com") or
|
2015-05-10 13:09:06 +02:00
|
|
|
|
string.match(msg.text, "steamcommunity.com/app/") or
|
2015-11-12 17:42:03 +01:00
|
|
|
|
string.match(msg.text, "myanimelist.net/anime/") or
|
2015-11-15 20:02:28 +01:00
|
|
|
|
string.match(msg.text, "myanimelist.net/manga/") or
|
2016-01-11 19:39:19 +01:00
|
|
|
|
string.match(msg.text, "myanimelist.net/profile/") or
|
2015-07-13 23:01:19 +02:00
|
|
|
|
string.match(msg.text, "deviantart.com") or
|
2015-07-18 15:33:35 +02:00
|
|
|
|
string.match(msg.text, "urbanup.com/") or
|
2015-11-12 17:42:03 +01:00
|
|
|
|
string.match(msg.text, "urbandictionary.com/define.php")or
|
2015-11-18 17:08:15 +01:00
|
|
|
|
string.match(msg.text, "wikia.com") or
|
|
|
|
|
string.match(msg.text, "rule34.xxx/index.php") or
|
2015-11-26 15:18:47 +01:00
|
|
|
|
string.match(msg.text, "openings.moe/%?video") or
|
2015-12-07 19:44:09 +01:00
|
|
|
|
string.match(msg.text, "myfigurecollection.net") or
|
2015-12-17 17:54:04 +01:00
|
|
|
|
string.match(msg.text, "dropbox.com/s/") or
|
2016-01-11 19:39:19 +01:00
|
|
|
|
string.match(msg.text, "nicovideo.jp/watch/sm") or
|
2015-12-17 17:54:04 +01:00
|
|
|
|
string.ends(url, ".jpg") or
|
|
|
|
|
string.ends(url, ".jpeg") or
|
|
|
|
|
string.ends(url, ".gif") or
|
|
|
|
|
string.ends(url, ".png") then
|
2015-07-13 23:01:19 +02:00
|
|
|
|
print('Ungültig, da "'..title..'"')
|
2015-04-14 20:21:23 +02:00
|
|
|
|
else
|
|
|
|
|
return title
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return {
|
2015-06-25 22:08:20 +02:00
|
|
|
|
description = "Postet den URL-Titel",
|
|
|
|
|
usage = {""},
|
|
|
|
|
patterns = {"^(https?://[%w-_%.%?%.:,/%+=&#!]+)$"},
|
2015-04-14 20:21:23 +02:00
|
|
|
|
run = run
|
|
|
|
|
}
|
|
|
|
|
end
|