Plugin für Aka's Blog!
gsub Fehler in url_title behoben
This commit is contained in:
parent
8ce6e87684
commit
79828a477a
83
plugins/akasblog.lua
Normal file
83
plugins/akasblog.lua
Normal file
@ -0,0 +1,83 @@
|
||||
do
|
||||
|
||||
local makeOurDate = function(dateString)
|
||||
local pattern = "(%d+)%-(%d+)%-(%d+)"
|
||||
local year, month, day = dateString:match(pattern)
|
||||
return day..'.'..month..'.'..year
|
||||
end
|
||||
|
||||
local function get_post(post)
|
||||
local url = 'http://akamaru.de/?json=get_post&post_id=blub'
|
||||
local res,code = http.request(url)
|
||||
local data = json:decode(res).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, "Ü", "Ü")
|
||||
|
||||
local from = data.author.name
|
||||
local date = makeOurDate(data.date)
|
||||
local teaser = string.gsub(data.excerpt, '\n', '')
|
||||
local url = data.url
|
||||
|
||||
local text = title..' ('..from..' am '..date..')\n\n'..teaser..'...\n'..url
|
||||
|
||||
return text
|
||||
end
|
||||
|
||||
local function run(msg, matches)
|
||||
local text = get_post(post)
|
||||
local text = string.gsub(text, "<p>", "")
|
||||
local text = string.gsub(text, "</p>", "")
|
||||
local receiver = get_receiver(msg)
|
||||
return text
|
||||
end
|
||||
|
||||
return {
|
||||
description = "Sendet letzten Aka's Blog Beitrag",
|
||||
usage = "/aka",
|
||||
patterns = {"^/[Aa][Kk][Aa]$"},
|
||||
run = run
|
||||
}
|
||||
|
||||
end
|
@ -31,7 +31,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, "€", "€")
|
||||
|
||||
|
Reference in New Issue
Block a user