rss.lua: dreckiger Weg um site_title zu bekommen
Änder ich später, wenn ich weiß wie ._.
This commit is contained in:
parent
95f00e5870
commit
4f6abf917e
@ -305,6 +305,15 @@ function rss:action(msg, config, matches)
|
||||
return
|
||||
end
|
||||
|
||||
function get_site_name(feed_link) --i know there's a better way to get this. But atm idc ¯\_(ツ)_/¯
|
||||
local iframely_api_key = cred_data.iframely_api_key
|
||||
local res, code = https.request('https://iframe.ly/api/oembed?url='..feed_link..'&api_key='..iframely_api_key)
|
||||
if code ~= 200 then return end
|
||||
local data = json.decode(res)
|
||||
local feed_name = data.provider_name
|
||||
return feed_name
|
||||
end
|
||||
|
||||
function rss:cron()
|
||||
local keys = redis:keys(get_base_redis("*", "subs"))
|
||||
for k,v in pairs(keys) do
|
||||
@ -317,11 +326,6 @@ function rss:cron()
|
||||
if err ~= nil then
|
||||
return
|
||||
end
|
||||
if not parsed.feed.title then
|
||||
feed_title = parsed.feed.link
|
||||
else
|
||||
feed_title = parsed.feed.title
|
||||
end
|
||||
local newentr = get_new_entries(last, parsed.entries)
|
||||
local subscribers = {}
|
||||
local text = '' -- Send one message per feed with the latest entries
|
||||
@ -339,6 +343,10 @@ function rss:cron()
|
||||
end
|
||||
local link_name = link_name:gsub('^www%.', '')
|
||||
local link_name = link_name:gsub('^www1%.', '')
|
||||
local site_title = get_site_name(link)
|
||||
if not site_title then
|
||||
site_title = link_name
|
||||
end
|
||||
|
||||
if v2.content then
|
||||
content = v2.content:gsub("%b<>", "")
|
||||
@ -363,7 +371,7 @@ function rss:cron()
|
||||
else
|
||||
content = ''
|
||||
end
|
||||
text = text..'\n<b>[</b>#RSS<b>] '..title..'</b>\n<i>'..feed_title..'</i>\n'..utilities.trim(content)..'\n<a href="'..link..'">Auf '..link_name..' ansehen.</a>\n'
|
||||
text = text..'\n<b>[</b>#RSS<b>] '..title..'</b>\n<i>~ '..site_title..' ~</i>\n'..utilities.trim(content)..'\n<a href="'..link..'">Auf '..link_name..' ansehen.</a>\n'
|
||||
end
|
||||
if text ~= '' then
|
||||
local newlast = newentr[1].id
|
||||
|
Reference in New Issue
Block a user