2016-01-30 21:03:21 +01:00
|
|
|
-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015+ <andi (dot) b (at) outlook (dot) de>
|
|
|
|
-- DO NOT USE WITHOUT PERMISSION
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
local _blacklist
|
|
|
|
|
|
|
|
local function show_blacklist()
|
|
|
|
if not _blacklist[1] then
|
2016-01-30 21:18:12 +01:00
|
|
|
return "Keine Wörter geblacklisted!\nBlackliste welche mit /imgblacklist add [Wort]"
|
2016-01-30 21:03:21 +01:00
|
|
|
else
|
|
|
|
local sort_alph = function( a,b ) return a < b end
|
|
|
|
table.sort( _blacklist, sort_alph )
|
2016-01-30 21:18:12 +01:00
|
|
|
local blacklist = "Folgende Wörter stehen auf der Blacklist:\n"
|
2016-01-30 21:03:21 +01:00
|
|
|
for v,word in pairs(_blacklist) do
|
|
|
|
blacklist = blacklist..'- '..word..'\n'
|
|
|
|
end
|
|
|
|
return blacklist
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function add_blacklist()
|
|
|
|
print('Blacklisting '..word..' - saving to redis set telegram:img_blacklist')
|
|
|
|
if redis:sismember("telegram:img_blacklist", word) == true then
|
|
|
|
return '"'..word..'" steht schon auf der Blacklist.'
|
|
|
|
else
|
|
|
|
redis:sadd("telegram:img_blacklist", word)
|
|
|
|
return '"'..word..'" blacklisted!'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function remove_blacklist()
|
|
|
|
print('De-blacklisting '..word..' - removing from redis set telegram:img_blacklist')
|
|
|
|
if redis:sismember("telegram:img_blacklist", word) == true then
|
|
|
|
redis:srem("telegram:img_blacklist", word)
|
2016-01-30 21:18:12 +01:00
|
|
|
return '"'..word..'" erfolgreich von der Blacklist gelöscht!'
|
2016-01-30 21:03:21 +01:00
|
|
|
else
|
|
|
|
return '"'..word..'" steht nicht auf der Blacklist.'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function run(msg, matches)
|
|
|
|
local action = matches[1]
|
|
|
|
if matches[2] then word = string.lower(matches[2]) end
|
|
|
|
_blacklist = redis:smembers("telegram:img_blacklist")
|
|
|
|
|
|
|
|
if action == "add" and word == nil then
|
2016-01-30 21:18:12 +01:00
|
|
|
return "Benutzung: /imgblacklist add [Wort]"
|
2016-01-30 21:03:21 +01:00
|
|
|
elseif action == "add" and word then
|
|
|
|
return add_blacklist()
|
|
|
|
end
|
|
|
|
|
|
|
|
if action == "remove" and word == nil then
|
2016-01-30 21:18:12 +01:00
|
|
|
return "Benutzung: /imgblacklist remove [Wort]"
|
2016-01-30 21:03:21 +01:00
|
|
|
elseif action == "remove" and word then
|
|
|
|
return remove_blacklist()
|
|
|
|
end
|
|
|
|
|
|
|
|
return show_blacklist()
|
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
2016-01-30 21:18:12 +01:00
|
|
|
description = "Blacklist-Manager für Bilder-Plugins (nur Superuser)",
|
2016-01-30 21:03:21 +01:00
|
|
|
usage = {
|
2016-06-22 13:59:06 +02:00
|
|
|
"#imgblacklist show: Zeigt Blacklist",
|
|
|
|
"#imgblacklist add [Wort]: Fügt Wort der Blacklist hinzu",
|
|
|
|
"#imgblacklist remove [Wort]: Entfernt Wort aus der Blacklist"
|
2016-01-30 21:03:21 +01:00
|
|
|
},
|
|
|
|
patterns = {
|
2016-06-22 13:59:06 +02:00
|
|
|
"^#imgblacklist show$",
|
|
|
|
"^#imgblacklist (add) (.*)$",
|
|
|
|
"^#imgblacklist (remove) (.*)$"
|
2016-01-30 21:03:21 +01:00
|
|
|
},
|
|
|
|
run = run,
|
|
|
|
privileged = true
|
|
|
|
}
|
|
|
|
end
|