- Imgblacklist überarbeitet
- Tagesschau_EIL: Fix?
This commit is contained in:
parent
1dcb1a3bbe
commit
0a94c93560
@ -6,7 +6,11 @@ local redis = (loadfile "./otouto/redis.lua")()
|
|||||||
imgblacklist.command = 'imgblacklist'
|
imgblacklist.command = 'imgblacklist'
|
||||||
|
|
||||||
function imgblacklist:init(config)
|
function imgblacklist:init(config)
|
||||||
imgblacklist.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('imgblacklist', true).table
|
imgblacklist.triggers = {
|
||||||
|
"^/imgblacklist show$",
|
||||||
|
"^/imgblacklist (add) (.*)$",
|
||||||
|
"^/imgblacklist (remove) (.*)$"
|
||||||
|
}
|
||||||
imgblacklist.doc = [[*
|
imgblacklist.doc = [[*
|
||||||
]]..config.cmd_pat..[[imgblacklist* _show_: Zeige Blacklist
|
]]..config.cmd_pat..[[imgblacklist* _show_: Zeige Blacklist
|
||||||
*]]..config.cmd_pat..[[imgblacklist* _add_ _<Wort>_: Fügt Wort der Blacklist hinzu
|
*]]..config.cmd_pat..[[imgblacklist* _add_ _<Wort>_: Fügt Wort der Blacklist hinzu
|
||||||
@ -47,30 +51,34 @@ function imgblacklist:remove_blacklist(word)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function imgblacklist:action(msg, config)
|
function imgblacklist:action(msg, config, matches)
|
||||||
if msg.from.id ~= config.admin then
|
if msg.from.id ~= config.admin then
|
||||||
utilities.send_reply(self, msg, config.errors.sudo)
|
utilities.send_reply(self, msg, config.errors.sudo)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local input = utilities.input(msg.text)
|
|
||||||
local input = string.lower(input)
|
local action = matches[1]
|
||||||
|
if matches[2] then word = string.lower(matches[2]) else word = nil end
|
||||||
_blacklist = redis:smembers("telegram:img_blacklist")
|
_blacklist = redis:smembers("telegram:img_blacklist")
|
||||||
|
|
||||||
if input:match('(add) (.*)') then
|
if action == 'add' and not word then
|
||||||
local word = input:match('add (.*)')
|
utilities.send_reply(self, msg, imgblacklist.doc, true)
|
||||||
output = imgblacklist:add_blacklist(word)
|
return
|
||||||
elseif input:match('(remove) (.*)') then
|
elseif action == "add" and word then
|
||||||
local word = input:match('remove (.*)')
|
utilities.send_reply(self, msg, imgblacklist:add_blacklist(word), true)
|
||||||
output = imgblacklist:remove_blacklist(word)
|
|
||||||
elseif input:match('(show)') then
|
|
||||||
output = imgblacklist:show_blacklist()
|
|
||||||
else
|
|
||||||
utilities.send_message(self, msg.chat.id, imgblacklist.doc, true, msg.message_id, true)
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
utilities.send_message(self, msg.chat.id, output, true, nil, true)
|
if action == 'remove' and not word then
|
||||||
|
utilities.send_reply(self, msg, imgblacklist.doc, true)
|
||||||
|
return
|
||||||
|
elseif action == "remove" and word then
|
||||||
|
utilities.send_reply(self, msg, imgblacklist:remove_blacklist(word), true)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
utilities.send_reply(self, msg, imgblacklist:show_blacklist())
|
||||||
end
|
end
|
||||||
|
|
||||||
return imgblacklist
|
return imgblacklist
|
||||||
|
@ -88,8 +88,8 @@ function tagesschau_eil:cron(self_plz)
|
|||||||
-- print('EIL: Prüfe...')
|
-- print('EIL: Prüfe...')
|
||||||
local last_eil = redis:get(hash..':last_entry')
|
local last_eil = redis:get(hash..':last_entry')
|
||||||
local res,code = http.request(url)
|
local res,code = http.request(url)
|
||||||
local data = json.decode(res)
|
|
||||||
if code ~= 200 then return end
|
if code ~= 200 then return end
|
||||||
|
local data = json.decode(res)
|
||||||
if not data then return end
|
if not data then return end
|
||||||
if data.breakingnews[1] then
|
if data.breakingnews[1] then
|
||||||
if data.breakingnews[1].date ~= last_eil then
|
if data.breakingnews[1].date ~= last_eil then
|
||||||
|
Reference in New Issue
Block a user