diff --git a/bot/utils.lua b/bot/utils.lua index 3242316..8481bdc 100644 --- a/bot/utils.lua +++ b/bot/utils.lua @@ -528,17 +528,51 @@ function round(num, idp) end function unescape(str) - str = string.gsub( str, '<', '<' ) - str = string.gsub( str, '>', '>' ) - str = string.gsub( str, '"', '"' ) - str = string.gsub( str, ''', "'" ) - str = string.gsub( str, "Ä", "Ä") - str = string.gsub( str, "ä", "ä") - str = string.gsub( str, "Ö", "Ö") - str = string.gsub( str, "ö", "ö") - str = string.gsub( str, "Uuml;", "Ü") - str = string.gsub( str, "ü", "ü") - str = string.gsub( str, "ß", "ß") + -- Character encoding + str = string.gsub(str, "´", "´") + str = string.gsub(str, "•", "•") + str = string.gsub(str, ">", ">") + str = string.gsub(str, "…", "…") + str = string.gsub(str, "<", "<") + str = string.gsub(str, "—", "—") + str = string.gsub(str, "∇", "∇") + str = string.gsub(str, "–", "–") + str = string.gsub(str, "Ψ", "ψ") + str = string.gsub(str, "ψ", "ψ") + str = string.gsub(str, """, '"') + str = string.gsub(str, "»", "»") + str = string.gsub(str, "®", "®") + str = string.gsub(str, "ß", "ß") + str = string.gsub(str, "™", "™") + str = string.gsub(str, "&", "&") + str = string.gsub(str, "'", "'") + str = string.gsub(str, "'", "'") + str = string.gsub(str, "|", "|") + str = string.gsub(str, " ", " ") + str = string.gsub(str, "®", "®") + str = string.gsub(str, "»", "»") + str = string.gsub(str, "ß", "ß") + str = string.gsub(str, "–", "–") + str = string.gsub(str, "’", "'") + str = string.gsub(str, "“", "“") + str = string.gsub(str, "”", "”") + str = string.gsub(str, "„", "„") + str = string.gsub(str, "‹", "‹") + str = string.gsub(str, "€", "€") + + -- Ä Ö Ü + str = string.gsub(str, "ä", "ä") + str = string.gsub(str, "Ä", "Ä") + str = string.gsub(str, "ä", "ä") + str = string.gsub(str, "Ä", "Ä") + str = string.gsub(str, "ö", "ö") + str = string.gsub(str, "Ö", "Ö") + str = string.gsub(str, "ö", "ö") + str = string.gsub(str, "Ö", "Ö") + str = string.gsub(str, "ü", "ü") + str = string.gsub(str, "Ü", "Ü") + str = string.gsub(str, "ü", "ü") + str = string.gsub(str, "Ü", "Ü") str = string.gsub( str, '&#(%d+);', function(n) return string.char(n) end ) str = string.gsub( str, '&#x(%d+);', function(n) return string.char(tonumber(n,16)) end ) str = string.gsub( str, '&', '&' ) -- Be sure to do this after all others diff --git a/plugins/akasblog.lua b/plugins/akasblog.lua index 656c5cf..c0698e0 100644 --- a/plugins/akasblog.lua +++ b/plugins/akasblog.lua @@ -13,52 +13,13 @@ local function get_post(post) if code ~= 200 then return "HTTP-Fehler" end if not data then return "HTTP-Fehler" end - local title = data.title - -- Character encoding - title = string.gsub(title, "´", "´") - title = string.gsub(title, "&", "&") - title = string.gsub(title, ">", ">") - title = string.gsub(title, """, '"') - title = string.gsub(title, "<", "<") - title = string.gsub(title, "—", "—") - title = string.gsub(title, "∇", "∇") - title = string.gsub(title, "–", "–") - title = string.gsub(title, "Ψ", "ψ") - title = string.gsub(title, "ψ", "ψ") - title = string.gsub(title, "»", "»") - title = string.gsub(title, "ß", "ß") - title = string.gsub(title, "™", "™") - title = string.gsub(title, "&", "&") - title = string.gsub(title, "'", "'") - title = string.gsub(title, "'", "'") - title = string.gsub(title, "|", "|") - title = string.gsub(title, " ", " ") - title = string.gsub(title, "»", "»") - title = string.gsub(title, "ß", "ß") - title = string.gsub(title, "–", "–") - title = string.gsub(title, "’", "'") - title = string.gsub(title, "“", "“") - title = string.gsub(title, "”", "”") - title = string.gsub(title, "„", "„") - title = string.gsub(title, "‹", "‹") - title = string.gsub(title, "€", "€") - -- Ä Ö Ü - title = string.gsub(title, "ä", "ä") - title = string.gsub(title, "Ä", "Ä") - title = string.gsub(title, "ä", "ä") - title = string.gsub(title, "Ä", "Ä") - title = string.gsub(title, "ö", "ö") - title = string.gsub(title, "Ö", "Ö") - title = string.gsub(title, "ö", "ö") - title = string.gsub(title, "Ö", "Ö") - title = string.gsub(title, "ü", "ü") - title = string.gsub(title, "Ü", "Ü") - title = string.gsub(title, "ü", "ü") - title = string.gsub(title, "Ü", "Ü") - + local title = unescape(data.title) local from = data.author.name local date = makeOurDate(data.date) - local content = string.match(data.excerpt, '

(.*)(.*)(.*)

')) + end local url = data.url if data.thumbnail then image_url = data.thumbnail diff --git a/plugins/akasblog_search.lua b/plugins/akasblog_search.lua index 42ffbd1..50d12c9 100644 --- a/plugins/akasblog_search.lua +++ b/plugins/akasblog_search.lua @@ -13,52 +13,13 @@ local function search_post(tag) if code ~= 200 then return "HTTP-Fehler" end if not data then return "Nichts gefunden!" end - local title = data.title - -- Character encoding - title = string.gsub(title, "´", "´") - title = string.gsub(title, "&", "&") - title = string.gsub(title, ">", ">") - title = string.gsub(title, """, '"') - title = string.gsub(title, "<", "<") - title = string.gsub(title, "—", "—") - title = string.gsub(title, "∇", "∇") - title = string.gsub(title, "–", "–") - title = string.gsub(title, "Ψ", "ψ") - title = string.gsub(title, "ψ", "ψ") - title = string.gsub(title, "»", "»") - title = string.gsub(title, "ß", "ß") - title = string.gsub(title, "™", "™") - title = string.gsub(title, "&", "&") - title = string.gsub(title, "'", "'") - title = string.gsub(title, "'", "'") - title = string.gsub(title, "|", "|") - title = string.gsub(title, " ", " ") - title = string.gsub(title, "»", "»") - title = string.gsub(title, "ß", "ß") - title = string.gsub(title, "–", "–") - title = string.gsub(title, "’", "'") - title = string.gsub(title, "“", "“") - title = string.gsub(title, "”", "”") - title = string.gsub(title, "„", "„") - title = string.gsub(title, "‹", "‹") - title = string.gsub(title, "€", "€") - -- Ä Ö Ü - title = string.gsub(title, "ä", "ä") - title = string.gsub(title, "Ä", "Ä") - title = string.gsub(title, "ä", "ä") - title = string.gsub(title, "Ä", "Ä") - title = string.gsub(title, "ö", "ö") - title = string.gsub(title, "Ö", "Ö") - title = string.gsub(title, "ö", "ö") - title = string.gsub(title, "Ö", "Ö") - title = string.gsub(title, "ü", "ü") - title = string.gsub(title, "Ü", "Ü") - title = string.gsub(title, "ü", "ü") - title = string.gsub(title, "Ü", "Ü") - + local title = unescape(data.title) local from = data.author.name local date = makeOurDate(data.date) - local content = string.match(data.excerpt, '

(.*)(.*)(.*)

')) + end local url = data.url if data.thumbnail then image_url = data.thumbnail diff --git a/plugins/ponywave.lua b/plugins/ponywave.lua index e1dd8da..c3b8729 100644 --- a/plugins/ponywave.lua +++ b/plugins/ponywave.lua @@ -13,52 +13,10 @@ local function get_post(post) if code ~= 200 then return "HTTP-Fehler" end if not data then return "HTTP-Fehler" end - local title = data.title - -- Character encoding - title = string.gsub(title, "´", "´") - title = string.gsub(title, "&", "&") - title = string.gsub(title, ">", ">") - title = string.gsub(title, """, '"') - title = string.gsub(title, "<", "<") - title = string.gsub(title, "—", "—") - title = string.gsub(title, "∇", "∇") - title = string.gsub(title, "–", "–") - title = string.gsub(title, "Ψ", "ψ") - title = string.gsub(title, "ψ", "ψ") - title = string.gsub(title, "»", "»") - title = string.gsub(title, "ß", "ß") - title = string.gsub(title, "™", "™") - title = string.gsub(title, "&", "&") - title = string.gsub(title, "'", "'") - title = string.gsub(title, "'", "'") - title = string.gsub(title, "|", "|") - title = string.gsub(title, " ", " ") - title = string.gsub(title, "»", "»") - title = string.gsub(title, "ß", "ß") - title = string.gsub(title, "–", "–") - title = string.gsub(title, "’", "'") - title = string.gsub(title, "“", "“") - title = string.gsub(title, "”", "”") - title = string.gsub(title, "„", "„") - title = string.gsub(title, "‹", "‹") - title = string.gsub(title, "€", "€") - -- Ä Ö Ü - title = string.gsub(title, "ä", "ä") - title = string.gsub(title, "Ä", "Ä") - title = string.gsub(title, "ä", "ä") - title = string.gsub(title, "Ä", "Ä") - title = string.gsub(title, "ö", "ö") - title = string.gsub(title, "Ö", "Ö") - title = string.gsub(title, "ö", "ö") - title = string.gsub(title, "Ö", "Ö") - title = string.gsub(title, "ü", "ü") - title = string.gsub(title, "Ü", "Ü") - title = string.gsub(title, "ü", "ü") - title = string.gsub(title, "Ü", "Ü") - + local title = unescape(data.title) local from = data.author.name local date = makeOurDate(data.date) - local content = string.match(data.excerpt, '

(.*)

') + local content = unescape(string.match(data.excerpt, '

(.*)

')) local url = data.url if data.thumbnail then image_url = data.thumbnail diff --git a/plugins/rss.lua b/plugins/rss.lua index d76c2c1..1fb72f9 100644 --- a/plugins/rss.lua +++ b/plugins/rss.lua @@ -1,44 +1,6 @@ feedparser = (loadfile "./libs/feedparser.lua")() -local function unescape_for_rss(str) - -- Character encoding - str = string.gsub(str, "´", "´") - str = string.gsub(str, ">", ">") - str = string.gsub(str, "<", "<") - str = string.gsub(str, "—", "—") - str = string.gsub(str, "∇", "∇") - str = string.gsub(str, "–", "–") - str = string.gsub(str, "Ψ", "ψ") - str = string.gsub(str, "ψ", "ψ") - str = string.gsub(str, "»", "»") - str = string.gsub(str, "ß", "ß") - str = string.gsub(str, "'", "'") - str = string.gsub(str, "|", "|") - str = string.gsub(str, " ", " ") - str = string.gsub(str, "»", "»") - str = string.gsub(str, "ß", "ß") - str = string.gsub(str, "–", "–") - str = string.gsub(str, "’", "'") - str = string.gsub(str, "“", "“") - str = string.gsub(str, "”", "”") - str = string.gsub(str, "„", "") - str = string.gsub(str, "‹", "‹") - str = string.gsub(str, "€", "€") - - -- Ä Ö Ü - str = string.gsub(str, "ä", "ä") - str = string.gsub(str, "Ä", "Ä") - str = string.gsub(str, "ä", "ä") - str = string.gsub(str, "Ä", "Ä") - str = string.gsub(str, "ö", "ö") - str = string.gsub(str, "Ö", "Ö") - str = string.gsub(str, "ö", "ö") - str = string.gsub(str, "Ö", "Ö") - str = string.gsub(str, "ü", "ü") - str = string.gsub(str, "Ü", "Ü") - str = string.gsub(str, "ü", "ü") - str = string.gsub(str, "Ü", "Ü") - +local function unescape_for_rss(str) str = string.gsub( str, '&#x(%d+);', function(n) return string.char(tonumber(n,16)) end ) str = string.gsub( str, '&', '&' ) -- Be sure to do this after all others return str @@ -180,19 +142,19 @@ local function cron() local subscribers = {} local text = '' -- Send one message per feed with the latest entries for k2, v2 in pairs(newentr) do - local title = v2.title or 'Kein Titel' + local title = unescape(v2.title) or 'Kein Titel' local link = v2.link or v2.id or 'Kein Link' if v2.content then if string.len(v2.content) > 250 then - content = string.sub(unescape_for_rss(v2.content:gsub("%b<>", "")), 1, 250) .. '...' + content = unescape(string.sub(unescape_for_rss(v2.content:gsub("%b<>", "")), 1, 250))..'...' else - content = unescape_for_rss(v2.content:gsub("%b<>", "")) + content = unescape(unescape_for_rss(v2.content:gsub("%b<>", ""))) end elseif v2.summary then if string.len(v2.summary) > 250 then - content = string.sub(unescape_for_rss(v2.summary:gsub("%b<>", "")), 1, 250) .. '...' + content = unescape(string.sub(unescape_for_rss(v2.summary:gsub("%b<>", "")), 1, 250))..'...' else - content = unescape_for_rss(v2.summary:gsub("%b<>", "")) + content = unescape(unescape_for_rss(v2.summary:gsub("%b<>", ""))) end else content = '' diff --git a/plugins/url_title.lua b/plugins/url_title.lua index c6b166b..d47676e 100644 --- a/plugins/url_title.lua +++ b/plugins/url_title.lua @@ -4,55 +4,8 @@ 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, " *> *", ">") - - -- Character encoding - 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, "∇", "∇") - 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, "ß", "ß") - 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, "®", "®") - 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, "„", "„") - 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, "ö", "ö") - 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, "Ü", "Ü") -- Put all the tags in lowercase. s = string.gsub(s, "(<[^ >]+)", string.lower) @@ -68,7 +21,7 @@ end function run(msg, matches) local url = matches[1] local result = http.request(url) - local title = getTitle(result) + local title = unescape(getTitle(result)) --Ignoring 301, 302, 404 and more if title == "301 Moved Permanently" or diff --git a/plugins/whereisip.lua b/plugins/whereisip.lua index 6eb7607..cb58b42 100644 --- a/plugins/whereisip.lua +++ b/plugins/whereisip.lua @@ -29,7 +29,10 @@ end return { description = "Send the origin of an IP or domain", - usage = {"!ip (ip): Send the origin of an IP.\n!ip (domain.com) Looks for his IP origin.\nYou can find your ip in: http://lorenzomoreno.es/myip Credits: @rutrus"}, + usage = {"/ip (ip): Send the origin of an IP.", + "/ip (domain.com) Looks for his IP origin.", + "You can find your ip in: http://lorenzomoreno.es/myip Credits: @rutrus" + }, patterns = { "^/whereisip$", "^/ip$",