Verbessere Plugin für Fefes Blog

This commit is contained in:
Andreas Bielawski 2016-10-06 14:48:38 +02:00
parent 1fa1041bcb
commit b428d59b1f

View File

@ -5,7 +5,7 @@ fefe.triggers = {
} }
function fefe:post(id) function fefe:post(id)
local url = 'http://'..id local url = 'https://'..id
local results, code = https.request(url) local results, code = https.request(url)
if code ~= 200 then return "HTTP-Fehler" end if code ~= 200 then return "HTTP-Fehler" end
if string.match(results, "No entries found.") then return "Eintrag nicht gefunden." end if string.match(results, "No entries found.") then return "Eintrag nicht gefunden." end
@ -16,17 +16,14 @@ function fefe:post(id)
local text = text:gsub("<li><a href=\"%?ts=%w%w%w%w%w%w%w%w\">%[l]</a>", "") local text = text:gsub("<li><a href=\"%?ts=%w%w%w%w%w%w%w%w\">%[l]</a>", "")
-- replace "<p>" with newline; "<b>" and "</b>" with "*" -- replace "<p>" with newline; "<b>" and "</b>" with "*"
local text = text:gsub("<p>", "\n\n"):gsub("<p u>", "\n\n") local text = text:gsub("<p>", "\n\n"):gsub("<p u>", "\n\n")
local text = text:gsub("<b>", "*"):gsub("</b>", "*")
local text = text:gsub("<i>", "_"):gsub("</i>", "_")
-- format quotes and links markdown-like -- format quotes and links markdown-like
local text = text:gsub("<a href=\"", "("):gsub("\">", ")["):gsub("</a>", "]")
local text = text:gsub("<blockquote>", "\n\n> "):gsub("</blockquote>", "\n\n") local text = text:gsub("<blockquote>", "\n\n> "):gsub("</blockquote>", "\n\n")
return text return text
end end
function fefe:action(msg, config, matches) function fefe:action(msg, config, matches)
utilities.send_reply(msg, fefe:post(matches[1])) utilities.send_reply(msg, fefe:post(matches[1]), 'HTML')
end end
return fefe return fefe