Merge Upstream

This commit is contained in:
Akamaru 2016-10-28 23:15:08 +02:00
commit bbb00530fc
5 changed files with 387 additions and 386 deletions

3
.gitignore vendored
View File

@ -8,4 +8,5 @@ msg.txt
merge.sh merge.sh
miku/plugins/link_warning.lua miku/plugins/link_warning.lua
luarocks luarocks
miku/plugins/gTrendDoge.lua miku/plugins/gTrendDoge.lua
miku/plugins/xrel_search.lua

View File

@ -25,7 +25,7 @@ function github:send_github_data(data)
if not data.owner then return nil end if not data.owner then return nil end
local name = '<b>'..data.name..'</b>' local name = '<b>'..data.name..'</b>'
if data.description then if data.description then
description = '<i>'..data.description..'</i>' description = '\n<i>'..data.description..'</i>'
else else
description = '' description = ''
end end
@ -46,7 +46,7 @@ function github:send_github_data(data)
else else
homepage = '\n<a href="'..data.homepage..'">Homepage besuchen</a>' homepage = '\n<a href="'..data.homepage..'">Homepage besuchen</a>'
end end
local text = name..' von '..owner..'\n'..description..'\n<pre>git clone '..clone_url..'</pre>'..language..issues..homepage local text = name..' von '..owner..description..'\n<pre>git clone '..clone_url..'</pre>'..language..issues..homepage
return text return text
end end

View File

@ -87,11 +87,11 @@ function notify:action(msg, config, matches)
redis:hset(hash, 'id', msg.from.id) redis:hset(hash, 'id', msg.from.id)
print('Adde '..username..' zu redis set notify:ls') print('Adde '..username..' zu redis set notify:ls')
redis:sadd('notify:ls', username) redis:sadd('notify:ls', username)
local res = utilities.send_message(msg.from.id, 'Du erhältst jetzt Benachrichtigungen, wenn du angesprochen wirst, nutze `/notify del` zum Deaktivieren.', true, nil, true) local res = utilities.send_message(msg.from.id, 'Du erhältst jetzt Benachrichtigungen, wenn du angesprochen wirst. Nutze `/notify del` zum Deaktivieren.', true, nil, true)
if not res then if not res then
utilities.send_reply(msg, 'Bitte schreibe mir [privat](http://telegram.me/' .. self.info.username .. '?start=notify), um den Vorgang abzuschließen.', true) utilities.send_reply(msg, 'Bitte schreibe mir [privat](http://telegram.me/' .. self.info.username .. '?start=notify), um den Vorgang abzuschließen.', true)
elseif msg.chat.type ~= 'private' then elseif msg.chat.type ~= 'private' then
utilities.send_reply(msg, 'Du erhältst jetzt Benachrichtigungen, wenn du angesprochen wirst, nutze `/notify del` zum Deaktivieren.', true) utilities.send_reply(msg, 'Du erhältst jetzt Benachrichtigungen, wenn du angesprochen wirst. Nutze `/notify del` zum Deaktivieren.', true)
end end
end end
end end

View File

@ -1,381 +1,381 @@
local rss = {} local rss = {}
local feedparser = require("feedparser") local feedparser = require("feedparser")
rss.command = 'rss <sub/del>' rss.command = 'rss <sub/del>'
function rss:init(config) function rss:init(config)
rss.triggers = { rss.triggers = {
"^/(rss) @(.*)$", "^/(rss) @(.*)$",
"^/rss$", "^/rss$",
"^/rss (sub) (https?://[%w-_%.%?%.:/%+=&%~]+) @(.*)$", "^/rss (sub) (https?://[%w-_%.%?%.:/%+=&%~]+) @(.*)$",
"^/rss (sub) (https?://[%w-_%.%?%.:/%+=&%~]+)$", "^/rss (sub) (https?://[%w-_%.%?%.:/%+=&%~]+)$",
"^/rss (del) (%d+) @(.*)$", "^/rss (del) (%d+) @(.*)$",
"^/rss (del) (%d+)$", "^/rss (del) (%d+)$",
"^/rss (del)$", "^/rss (del)$",
"^/rss (sync)$" "^/rss (sync)$"
} }
rss.doc = [[* rss.doc = [[*
]]..config.cmd_pat..[[rss* _@[Kanalname]_: Feed-Abonnements anzeigen ]]..config.cmd_pat..[[rss* _@[Kanalname]_: Feed-Abonnements anzeigen
*]]..config.cmd_pat..[[rss* _sub_ _<URL>_ _@[Kanalname]_: Diesen Feed abonnieren *]]..config.cmd_pat..[[rss* _sub_ _<URL>_ _@[Kanalname]_: Diesen Feed abonnieren
*]]..config.cmd_pat..[[rss* _del_ _<#>_ _@[Kanalname]_: Diesen Feed deabonnieren *]]..config.cmd_pat..[[rss* _del_ _<#>_ _@[Kanalname]_: Diesen Feed deabonnieren
*]]..config.cmd_pat..[[rss* _sync_: Feeds syncen (nur Superuser) *]]..config.cmd_pat..[[rss* _sync_: Feeds syncen (nur Superuser)
Der Kanalname ist optional]] Der Kanalname ist optional]]
end end
function tail(n, k) function tail(n, k)
local u, r='' local u, r=''
for i=1,k do for i=1,k do
n,r = math.floor(n/0x40), n%0x40 n,r = math.floor(n/0x40), n%0x40
u = string.char(r+0x80) .. u u = string.char(r+0x80) .. u
end end
return u, n return u, n
end end
function to_utf8(a) function to_utf8(a)
local n, r, u = tonumber(a) local n, r, u = tonumber(a)
if n<0x80 then -- 1 byte if n<0x80 then -- 1 byte
return string.char(n) return string.char(n)
elseif n<0x800 then -- 2 byte elseif n<0x800 then -- 2 byte
u, n = tail(n, 1) u, n = tail(n, 1)
return string.char(n+0xc0) .. u return string.char(n+0xc0) .. u
elseif n<0x10000 then -- 3 byte elseif n<0x10000 then -- 3 byte
u, n = tail(n, 2) u, n = tail(n, 2)
return string.char(n+0xe0) .. u return string.char(n+0xe0) .. u
elseif n<0x200000 then -- 4 byte elseif n<0x200000 then -- 4 byte
u, n = tail(n, 3) u, n = tail(n, 3)
return string.char(n+0xf0) .. u return string.char(n+0xf0) .. u
elseif n<0x4000000 then -- 5 byte elseif n<0x4000000 then -- 5 byte
u, n = tail(n, 4) u, n = tail(n, 4)
return string.char(n+0xf8) .. u return string.char(n+0xf8) .. u
else -- 6 byte else -- 6 byte
u, n = tail(n, 5) u, n = tail(n, 5)
return string.char(n+0xfc) .. u return string.char(n+0xfc) .. u
end end
end end
function cleanRSS(str) function cleanRSS(str)
str = string.gsub(str, '%[%…%]', '') str = string.gsub(str, '%[%…%]', '')
str = string.gsub(str, '%[bilder%]', '') str = string.gsub(str, '%[bilder%]', '')
str = string.gsub(str, '%[mehr%]', '') str = string.gsub(str, '%[mehr%]', '')
str = string.gsub(str, '%[video%]', '') str = string.gsub(str, '%[video%]', '')
str = string.gsub(str, '...%[more%]', '') str = string.gsub(str, '...%[more%]', '')
str = string.gsub(str, '%[more%]', '') str = string.gsub(str, '%[more%]', '')
str = string.gsub(str, '%[liveticker%]', '') str = string.gsub(str, '%[liveticker%]', '')
str = string.gsub(str, '%[livestream%]', '') str = string.gsub(str, '%[livestream%]', '')
str = string.gsub(str, '%[multimedia%]', '') str = string.gsub(str, '%[multimedia%]', '')
str = string.gsub(str, '%[phoenix%]', '') str = string.gsub(str, '%[phoenix%]', '')
str = string.gsub(str, '%[swr%]', '') str = string.gsub(str, '%[swr%]', '')
str = string.gsub(str, '%[ndr%]', '') str = string.gsub(str, '%[ndr%]', '')
str = string.gsub(str, '%[mdr%]', '') str = string.gsub(str, '%[mdr%]', '')
str = string.gsub(str, '%[rbb%]', '') str = string.gsub(str, '%[rbb%]', '')
str = string.gsub(str, '%[wdr%]', '') str = string.gsub(str, '%[wdr%]', '')
str = string.gsub(str, '%[hr%]', '') str = string.gsub(str, '%[hr%]', '')
str = string.gsub(str, '%[br%]', '') str = string.gsub(str, '%[br%]', '')
str = string.gsub(str, 'Click for full.', '') str = string.gsub(str, 'Click for full.', '')
str = string.gsub(str, 'Read more »', '') str = string.gsub(str, 'Read more »', '')
str = string.gsub(str, 'Read more', '') str = string.gsub(str, 'Read more', '')
str = string.gsub(str, '%(more…%)', '') str = string.gsub(str, '%(more…%)', '')
str = string.gsub(str, 'View On WordPress', '') str = string.gsub(str, 'View On WordPress', '')
str = string.gsub(str, '%(RSS generated with FetchRss%)', '') str = string.gsub(str, '%(RSS generated with FetchRss%)', '')
str = string.gsub(str, '-- Delivered by Feed43 service', '') str = string.gsub(str, '-- Delivered by Feed43 service', '')
str = string.gsub(str, 'Meldung bei www%.tagesschau%.de lesen', '') str = string.gsub(str, 'Meldung bei www%.tagesschau%.de lesen', '')
str = string.gsub(str, 'The post.*appeared first on Sugoi! Anime Blog%.', '') str = string.gsub(str, 'The post.*appeared first on Sugoi! Anime Blog%.', '')
str = string.gsub(str, 'Der Beitrag.*erschien zuerst auf MAnime%.de%.', '') str = string.gsub(str, 'Der Beitrag.*erschien zuerst auf MAnime%.de%.', '')
str = string.gsub(str, 'http://www%.serienjunkies%.de/.*%.html', '') str = string.gsub(str, 'http://www%.serienjunkies%.de/.*%.html', '')
return str return str
end end
function get_base_redis(id, option, extra) function get_base_redis(id, option, extra)
local ex = '' local ex = ''
if option ~= nil then if option ~= nil then
ex = ex .. ':' .. option ex = ex .. ':' .. option
if extra ~= nil then if extra ~= nil then
ex = ex .. ':' .. extra ex = ex .. ':' .. extra
end end
end end
return 'rss:' .. id .. ex return 'rss:' .. id .. ex
end end
function prot_url(url) function prot_url(url)
local url, h = string.gsub(url, "http://", "") local url, h = string.gsub(url, "http://", "")
local url, hs = string.gsub(url, "https://", "") local url, hs = string.gsub(url, "https://", "")
local protocol = "http" local protocol = "http"
if hs == 1 then if hs == 1 then
protocol = "https" protocol = "https"
end end
return url, protocol return url, protocol
end end
function get_rss(url, prot) function get_rss(url, prot)
local res, code = nil, 0 local res, code = nil, 0
if prot == "http" then if prot == "http" then
res, code = http.request(url) res, code = http.request(url)
elseif prot == "https" then elseif prot == "https" then
res, code = https.request(url) res, code = https.request(url)
end end
if code ~= 200 then if code ~= 200 then
return nil, "Fehler beim Erreichen von " .. url return nil, "Fehler beim Erreichen von " .. url
end end
local parsed = feedparser.parse(res) local parsed = feedparser.parse(res)
if parsed == nil then if parsed == nil then
return nil, "Fehler beim Dekodieren des Feeds.\nBist du sicher, dass "..url.." ein Feed ist?" return nil, "Fehler beim Dekodieren des Feeds.\nBist du sicher, dass "..url.." ein Feed ist?"
end end
return parsed, nil return parsed, nil
end end
function get_new_entries(last, nentries) function get_new_entries(last, nentries)
local entries = {} local entries = {}
for k,v in pairs(nentries) do for k,v in pairs(nentries) do
if v.id == last then if v.id == last then
return entries return entries
else else
table.insert(entries, v) table.insert(entries, v)
end end
end end
return entries return entries
end end
function rss:subscribe(id, url) function rss:subscribe(id, url)
local baseurl, protocol = prot_url(url) local baseurl, protocol = prot_url(url)
local prothash = get_base_redis(baseurl, "protocol") local prothash = get_base_redis(baseurl, "protocol")
local lasthash = get_base_redis(baseurl, "last_entry") local lasthash = get_base_redis(baseurl, "last_entry")
local lhash = get_base_redis(baseurl, "subs") local lhash = get_base_redis(baseurl, "subs")
local uhash = get_base_redis(id) local uhash = get_base_redis(id)
if redis:sismember(uhash, baseurl) then if redis:sismember(uhash, baseurl) then
return "Du hast <code>"..url.."</code> bereits abonniert." return "Du hast <code>"..url.."</code> bereits abonniert."
end end
local parsed, err = get_rss(url, protocol) local parsed, err = get_rss(url, protocol)
if err ~= nil then if err ~= nil then
return err return err
end end
local last_entry = "" local last_entry = ""
if #parsed.entries > 0 then if #parsed.entries > 0 then
last_entry = parsed.entries[1].id last_entry = parsed.entries[1].id
end end
local name = parsed.feed.title local name = parsed.feed.title
redis:set(prothash, protocol) redis:set(prothash, protocol)
redis:set(lasthash, last_entry) redis:set(lasthash, last_entry)
redis:sadd(lhash, id) redis:sadd(lhash, id)
redis:sadd(uhash, baseurl) redis:sadd(uhash, baseurl)
return "<i>"..name.."</i> abonniert!" return "<i>"..name.."</i> abonniert!"
end end
function rss:unsubscribe(id, n) function rss:unsubscribe(id, n)
if #n > 5 then if #n > 5 then
return "Du kannst nicht mehr als fünf Feeds abonnieren!" return "Du kannst nicht mehr als fünf Feeds abonnieren!"
end end
n = tonumber(n) n = tonumber(n)
local uhash = get_base_redis(id) local uhash = get_base_redis(id)
local subs = redis:smembers(uhash) local subs = redis:smembers(uhash)
if n < 1 or n > #subs then if n < 1 or n > #subs then
return "Abonnement-ID zu hoch!" return "Abonnement-ID zu hoch!"
end end
local sub = subs[n] local sub = subs[n]
local lhash = get_base_redis(sub, "subs") local lhash = get_base_redis(sub, "subs")
redis:srem(uhash, sub) redis:srem(uhash, sub)
redis:srem(lhash, id) redis:srem(lhash, id)
local left = redis:smembers(lhash) local left = redis:smembers(lhash)
if #left < 1 then -- no one subscribed, remove it if #left < 1 then -- no one subscribed, remove it
local prothash = get_base_redis(sub, "protocol") local prothash = get_base_redis(sub, "protocol")
local lasthash = get_base_redis(sub, "last_entry") local lasthash = get_base_redis(sub, "last_entry")
redis:del(prothash) redis:del(prothash)
redis:del(lasthash) redis:del(lasthash)
end end
return "Du hast <code>"..sub.."</code> deabonniert." return "Du hast <code>"..sub.."</code> deabonniert."
end end
function rss:print_subs(id, chat_name) function rss:print_subs(id, chat_name)
local uhash = get_base_redis(id) local uhash = get_base_redis(id)
local subs = redis:smembers(uhash) local subs = redis:smembers(uhash)
if not subs[1] then if not subs[1] then
return '<b>Keine Feeds abonniert!</b>' return '<b>Keine Feeds abonniert!</b>'
end end
local keyboard = '{"keyboard":[[' local keyboard = '{"keyboard":[['
local keyboard_buttons = '' local keyboard_buttons = ''
local text = '<b>'..chat_name..'</b> hat abonniert:\n---------\n' local text = '<b>'..chat_name..'</b> hat abonniert:\n---------\n'
for k,v in pairs(subs) do for k,v in pairs(subs) do
text = text .. k .. ") " .. v .. '\n' text = text .. k .. ") " .. v .. '\n'
if k == #subs then if k == #subs then
keyboard_buttons = keyboard_buttons..'{"text":"/rss del '..k..'"}' keyboard_buttons = keyboard_buttons..'{"text":"/rss del '..k..'"}'
break; break;
end end
keyboard_buttons = keyboard_buttons..'{"text":"/rss del '..k..'"},' keyboard_buttons = keyboard_buttons..'{"text":"/rss del '..k..'"},'
end end
local keyboard = keyboard..keyboard_buttons..']], "one_time_keyboard":true, "selective":true, "resize_keyboard":true}' local keyboard = keyboard..keyboard_buttons..']], "one_time_keyboard":true, "selective":true, "resize_keyboard":true}'
return text, keyboard return text, keyboard
end end
function rss:action(msg, config, matches) function rss:action(msg, config, matches)
local id = "user#id" .. msg.from.id local id = "user#id" .. msg.from.id
if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then
id = 'chat#id'..msg.chat.id id = 'chat#id'..msg.chat.id
end end
-- For channels -- For channels
if matches[1] == 'sub' and matches[2] and matches[3] then if matches[1] == 'sub' and matches[2] and matches[3] then
if not is_sudo(msg, config) then if not is_sudo(msg, config) then
utilities.send_reply(msg, config.errors.sudo, true) utilities.send_reply(msg, config.errors.sudo, true)
return return
end end
local id = '@'..matches[3] local id = '@'..matches[3]
local result = utilities.get_chat_info(id) local result = utilities.get_chat_info(id)
if not result then if not result then
utilities.send_reply(msg, 'Diesen Kanal gibt es nicht!') utilities.send_reply(msg, 'Diesen Kanal gibt es nicht!')
return return
end end
local output = rss:subscribe(id, matches[2]) local output = rss:subscribe(id, matches[2])
utilities.send_reply(msg, output, 'HTML') utilities.send_reply(msg, output, 'HTML')
return return
elseif matches[1] == 'del' and matches[2] and matches[3] then elseif matches[1] == 'del' and matches[2] and matches[3] then
if not is_sudo(msg, config) then if not is_sudo(msg, config) then
utilities.send_reply(msg, config.errors.sudo, true) utilities.send_reply(msg, config.errors.sudo, true)
return return
end end
local id = '@'..matches[3] local id = '@'..matches[3]
local result = utilities.get_chat_info(id) local result = utilities.get_chat_info(id)
if not result then if not result then
utilities.send_reply(msg, 'Diesen Kanal gibt es nicht!') utilities.send_reply(msg, 'Diesen Kanal gibt es nicht!')
return return
end end
local output = rss:unsubscribe(id, matches[2]) local output = rss:unsubscribe(id, matches[2])
utilities.send_reply(msg, output, 'HTML') utilities.send_reply(msg, output, 'HTML')
return return
elseif matches[1] == 'rss' and matches[2] then elseif matches[1] == 'rss' and matches[2] then
local id = '@'..matches[2] local id = '@'..matches[2]
local result = utilities.get_chat_info(id) local result = utilities.get_chat_info(id)
if not result then if not result then
utilities.send_reply(msg, 'Diesen Kanal gibt es nicht!') utilities.send_reply(msg, 'Diesen Kanal gibt es nicht!')
return return
end end
local chat_name = result.result.title local chat_name = result.result.title
local output = rss:print_subs(id, chat_name) local output = rss:print_subs(id, chat_name)
utilities.send_reply(msg, output, 'HTML') utilities.send_reply(msg, output, 'HTML')
return return
end end
if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then
chat_name = msg.chat.title chat_name = msg.chat.title
else else
chat_name = msg.chat.first_name chat_name = msg.chat.first_name
end end
if matches[1] == 'sub' and matches[2] then if matches[1] == 'sub' and matches[2] then
if not is_sudo(msg, config) then if not is_sudo(msg, config) then
utilities.send_reply(msg, config.errors.sudo, true) utilities.send_reply(msg, config.errors.sudo, true)
return return
end end
local output = rss:subscribe(id, matches[2]) local output = rss:subscribe(id, matches[2])
utilities.send_reply(msg, output, 'HTML') utilities.send_reply(msg, output, 'HTML')
return return
elseif matches[1] == 'del' and matches[2] then elseif matches[1] == 'del' and matches[2] then
if not is_sudo(msg, config) then if not is_sudo(msg, config) then
utilities.send_reply(msg, config.errors.sudo, true) utilities.send_reply(msg, config.errors.sudo, true)
return return
end end
local output = rss:unsubscribe(id, matches[2]) local output = rss:unsubscribe(id, matches[2])
utilities.send_reply(msg, output, 'HTML', '{"hide_keyboard":true}') utilities.send_reply(msg, output, 'HTML', '{"hide_keyboard":true}')
return return
elseif matches[1] == 'del' and not matches[2] then elseif matches[1] == 'del' and not matches[2] then
local list_subs, keyboard = rss:print_subs(id, chat_name) local list_subs, keyboard = rss:print_subs(id, chat_name)
utilities.send_reply(msg, list_subs, 'HTML', keyboard) utilities.send_reply(msg, list_subs, 'HTML', keyboard)
return return
elseif matches[1] == 'sync' then elseif matches[1] == 'sync' then
if not is_sudo(msg, config) then if not is_sudo(msg, config) then
utilities.send_reply(msg, config.errors.sudo, true) utilities.send_reply(msg, config.errors.sudo, true)
return return
end end
rss:cron() rss:cron()
return return
end end
local output = rss:print_subs(id, chat_name) local output = rss:print_subs(id, chat_name)
utilities.send_reply(msg, output, 'HTML') utilities.send_reply(msg, output, 'HTML')
return return
end end
function rss:cron() function rss:cron()
local keys = redis:keys(get_base_redis("*", "subs")) local keys = redis:keys(get_base_redis("*", "subs"))
for k,v in pairs(keys) do for k,v in pairs(keys) do
local base = string.match(v, "rss:(.+):subs") -- Get the URL base local base = string.match(v, "rss:(.+):subs") -- Get the URL base
print('Checke RSS: '..base) print('Checke RSS: '..base)
local prot = redis:get(get_base_redis(base, "protocol")) local prot = redis:get(get_base_redis(base, "protocol"))
local last = redis:get(get_base_redis(base, "last_entry")) local last = redis:get(get_base_redis(base, "last_entry"))
local url = prot .. "://" .. base local url = prot .. "://" .. base
local parsed, err = get_rss(url, prot) local parsed, err = get_rss(url, prot)
if err ~= nil then if err ~= nil then
return return
end end
if not parsed.feed.title then if not parsed.feed.title then
feed_title = parsed.feed.link feed_title = parsed.feed.link
else else
feed_title = parsed.feed.title feed_title = parsed.feed.title
end end
local newentr = get_new_entries(last, parsed.entries) local newentr = get_new_entries(last, parsed.entries)
local subscribers = {} local subscribers = {}
local text = '' -- Send one message per feed with the latest entries local text = '' -- Send one message per feed with the latest entries
for k2, v2 in pairs(newentr) do for k2, v2 in pairs(newentr) do
local title = unescape(v2.title) or 'Kein Titel' local title = unescape(v2.title) or 'Kein Titel'
local link = v2.link or v2.id or 'Kein Link' local link = v2.link or v2.id or 'Kein Link'
if string.match(link, '//') then if string.match(link, '//') then
link_name = link:match('//([^/]+)') link_name = link:match('//([^/]+)')
else else
link_name = link link_name = link
end end
if link_name == 'feedproxy.google.com' then if link_name == 'feedproxy.google.com' then
link_name = link:match('feedproxy%.google%.com/~r/(.+)/~') link_name = link:match('feedproxy%.google%.com/~r/(.+)/~')
end end
local link_name = link_name:gsub('^www%.', '') local link_name = link_name:gsub('^www%.', '')
local link_name = link_name:gsub('^www1%.', '') local link_name = link_name:gsub('^www1%.', '')
if v2.content then if v2.content then
content = v2.content:gsub("%b<>", "") content = v2.content:gsub("%b<>", "")
if string.len(v2.content) > 250 then if string.len(v2.content) > 250 then
content = cleanRSS(content) content = cleanRSS(content)
content = unescape(content) content = unescape(content)
content = string.sub(content, 1, 250)..'...' content = string.sub(content, 1, 250)..'...'
else else
content = cleanRSS(content) content = cleanRSS(content)
content = unescape(content) content = unescape(content)
end end
elseif v2.summary then elseif v2.summary then
content = v2.summary:gsub("%b<>", "") content = v2.summary:gsub("%b<>", "")
if string.len(v2.summary) > 250 then if string.len(v2.summary) > 250 then
content = cleanRSS(content) content = cleanRSS(content)
content = unescape(content) content = unescape(content)
content = string.sub(content, 1, 250)..'...' content = string.sub(content, 1, 250)..'...'
else else
content = cleanRSS(content) content = cleanRSS(content)
content = unescape(content) content = unescape(content)
end end
else else
content = '' content = ''
end end
local content = content:gsub('\n', '') local content = content:gsub('\n', '')
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>'..feed_title..'</i>\n'..utilities.trim(content)..'\n<a href="'..link..'">Auf '..link_name..' ansehen.</a>\n'
end end
if text ~= '' then if text ~= '' then
local newlast = newentr[1].id local newlast = newentr[1].id
redis:set(get_base_redis(base, "last_entry"), newlast) redis:set(get_base_redis(base, "last_entry"), newlast)
for k2, receiver in pairs(redis:smembers(v)) do for k2, receiver in pairs(redis:smembers(v)) do
local receiver = string.gsub(receiver, 'chat%#id', '') local receiver = string.gsub(receiver, 'chat%#id', '')
local receiver = string.gsub(receiver, 'user%#id', '') local receiver = string.gsub(receiver, 'user%#id', '')
utilities.send_message(receiver, text, true, nil, 'HTML') utilities.send_message(receiver, text, true, nil, 'HTML')
end end
end end
end end
end end
return rss return rss

View File

@ -80,7 +80,7 @@ function shell:action(msg, config, matches)
-- Requires fswebcam (sudo apt-get install fswebcam) -- Requires fswebcam (sudo apt-get install fswebcam)
if msg.text:match('^/[Ww][Ee][Bb][Cc][Aa][Mm]$') then if msg.text:match('^/[Ww][Ee][Bb][Cc][Aa][Mm]$') then
run_command("fswebcam -r 640x480 --png 9 -D 1 /tmp/webcam.png") run_command("fswebcam -r 1280x1024 --png 9 -D 1 /tmp/webcam.png")
utilities.send_photo(msg.chat.id, '/tmp/webcam.png', nil, msg.message_id) utilities.send_photo(msg.chat.id, '/tmp/webcam.png', nil, msg.message_id)
return return
end end