cowsay nun mit inline & cleanRSS VOR unescape in rss.lua

This commit is contained in:
Akamaru 2016-08-21 19:59:36 +02:00
parent d372d26c15
commit 43b313e64e
2 changed files with 32 additions and 6 deletions

View File

@ -2,11 +2,25 @@ local cowsay = {}
function cowsay:init(config)
cowsay.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('cowsay', true).table
cowsay.inline_triggers = {'^cow (.+)$'}
cowsay.doc = '\n*/cowsay* _<Text>_'
end
cowsay.command = 'cowsay <Text>'
function cowsay:inline_callback(inline_query, config, matches)
local input = matches[1]
if string.match(input, '"') then utilities.answer_inline_query(self, inline_query) return end
local text = '```'..run_command('cowsay "'..input..'"')..'```'
local text = text:gsub('\\', '\\\\')
local results = '[{"type":"article","id":"7912","title":"Muh!","input_message_content":{"message_text":"'..text..'","parse_mode":"Markdown"}}]'
utilities.answer_inline_query(self, inline_query, results, 2)
end
function cowsay:action(msg, config)
local input = utilities.input_from_msg(msg)
if not input then
@ -23,4 +37,4 @@ function cowsay:action(msg, config)
utilities.send_reply(self, msg, text, true)
end
return cowsay
return cowsay

View File

@ -59,8 +59,16 @@ function cleanRSS(str)
str = string.gsub(str, '%[video%]', '')
str = string.gsub(str, '...%[more%]', '')
str = string.gsub(str, '%[more%]', '')
str = string.gsub(str, '%[liveticker%]', '')
str = string.gsub(str, '%[livestream%]', '')
str = string.gsub(str, '%[multimedia%]', '')
str = string.gsub(str, '%[phoenix%]', '')
str = string.gsub(str, '%[swr%]', '')
str = string.gsub(str, '%[ndr%]', '')
str = string.gsub(str, '%[mdr%]', '')
str = string.gsub(str, '%[wdr%]', '')
str = string.gsub(str, '%[hr%]', '')
str = string.gsub(str, '%[br%]', '')
str = string.gsub(str, 'Click for full.', '')
str = string.gsub(str, 'Read more »', '')
str = string.gsub(str, 'Read more', '')
@ -68,6 +76,7 @@ function cleanRSS(str)
str = string.gsub(str, 'View On WordPress', '')
str = string.gsub(str, '%(RSS generated with FetchRss%)', '')
str = string.gsub(str, 'Meldung bei www%.tagesschau%.de lesen', '')
str = string.gsub(str, 'http://www%.serienjunkies%.de/.*%.html', '')
return str
end
@ -297,7 +306,7 @@ function rss:cron(self_plz)
local keys = redis:keys(get_base_redis("*", "subs"))
for k,v in pairs(keys) do
local base = string.match(v, "rss:(.+):subs") -- Get the URL base
print('RSS: '..base)
print('Checke RSS: '..base)
local prot = redis:get(get_base_redis(base, "protocol"))
local last = redis:get(get_base_redis(base, "last_entry"))
local url = prot .. "://" .. base
@ -315,23 +324,26 @@ function rss:cron(self_plz)
if v2.content then
content = v2.content:gsub("%b<>", "")
if string.len(v2.content) > 300 then
content = cleanRSS(content)
content = unescape(content)
content = string.sub(content, 1, 300)..'...'
else
content = unescape(content)
content = cleanRSS(content)
content = unescape(content)
end
elseif v2.summary then
content = v2.summary:gsub("%b<>", "")
if string.len(v2.summary) > 300 then
content = unescape(content)
content = cleanRSS(content)
content = unescape(content)
content = string.sub(content, 1, 300)..'...'
else
content = unescape(content)
content = cleanRSS(content)
content = unescape(content)
end
else
content = ''
end
content = cleanRSS(content)
text = text..'\n<b>[</b>#RSS<b>] '..title..'</b>\n'..utilities.trim(content)..' <a href="'..link..'">Weiterlesen</a>\n'
end
if text ~= '' then