blacklist Verwaltung aus img_google entfernt
This commit is contained in:
		@@ -28,40 +28,6 @@ local function is_blacklisted(msg)
 | 
			
		||||
  return var
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function show_blacklist()
 | 
			
		||||
  if not _blacklist[1] then
 | 
			
		||||
    return "Keine Wörter geblacklisted!\nBlackliste welche mit !imgblacklist add [Wort]"
 | 
			
		||||
  else
 | 
			
		||||
    local sort_alph = function( a,b ) return a < b end
 | 
			
		||||
    table.sort( _blacklist, sort_alph )
 | 
			
		||||
    local blacklist = "Folgende Wörter stehen auf der Blacklist:\n"
 | 
			
		||||
    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)
 | 
			
		||||
    return '"'..word..'" erfolgreich von der Blacklist gelöscht!'
 | 
			
		||||
  else
 | 
			
		||||
    return '"'..word..'" steht nicht auf der Blacklist.'
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function cache_google_image(results, text)
 | 
			
		||||
  local cache = {}
 | 
			
		||||
  for v in pairs(results) do
 | 
			
		||||
@@ -77,34 +43,6 @@ function run(msg, matches)
 | 
			
		||||
  
 | 
			
		||||
  _blacklist = redis:smembers("telegram:img_blacklist")
 | 
			
		||||
  
 | 
			
		||||
  if text == "/imgblacklist show" then
 | 
			
		||||
    if is_sudo(msg) then
 | 
			
		||||
      return show_blacklist()
 | 
			
		||||
	else
 | 
			
		||||
	  return "Du bist kein Superuser. Dieser Vorfall wird gemeldet!"
 | 
			
		||||
	end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
  if text == "/imgblacklist add" and word == nil then
 | 
			
		||||
    return "Benutzung: !imgblacklist add [Wort]"
 | 
			
		||||
  elseif text == "!imgblacklist add" and word then
 | 
			
		||||
    if is_sudo(msg) then
 | 
			
		||||
      return add_blacklist()
 | 
			
		||||
	else
 | 
			
		||||
	  return "Du bist kein Superuser. Dieser Vorfall wird gemeldet!"
 | 
			
		||||
	end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
  if text == "/imgblacklist remove" and word == nil then
 | 
			
		||||
    return "Benutzung: !imgblacklist remove [Wort]"
 | 
			
		||||
  elseif text == "!imgblacklist remove" and word then
 | 
			
		||||
    if is_sudo(msg) then
 | 
			
		||||
      return remove_blacklist()
 | 
			
		||||
	else
 | 
			
		||||
	  return "Du bist kein Superuser. Dieser Vorfall wird gemeldet!"
 | 
			
		||||
	end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
  print ('Checking if search contains blacklisted words: '..text)
 | 
			
		||||
  if is_blacklisted(text) then
 | 
			
		||||
    return "Vergiss es ._."
 | 
			
		||||
@@ -157,16 +95,10 @@ end
 | 
			
		||||
return {
 | 
			
		||||
  description = "Sucht Bild mit Google-API und versendet es (SafeSearch aktiv)", 
 | 
			
		||||
  usage = {
 | 
			
		||||
    "/img [Suchbegriff]",
 | 
			
		||||
	"/imgblacklist show: Zeigt Blacklist (nur Superuser)",
 | 
			
		||||
	"/imgblacklist add [Wort]: Fügt Wort der Blacklist hinzu (nur Superuser)",
 | 
			
		||||
	"/imgblacklist remove [Wort]: Entfernt Wort aus der Blacklist (nur Superuser)"
 | 
			
		||||
    "/oldimg [Suchbegriff]"
 | 
			
		||||
  },
 | 
			
		||||
  patterns = {
 | 
			
		||||
    "^/img (.*)$",
 | 
			
		||||
	"^(/imgblacklist show)$",
 | 
			
		||||
	"^(/imgblacklist add) (.*)$",
 | 
			
		||||
	"^(/imgblacklist remove) (.*)$"
 | 
			
		||||
    "^/oldimg (.*)$"
 | 
			
		||||
  }, 
 | 
			
		||||
  run = run 
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -28,20 +28,6 @@ local function is_blacklisted(msg)
 | 
			
		||||
  return var
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function show_blacklist()
 | 
			
		||||
  if not _blacklist[1] then
 | 
			
		||||
    return "Keine Wörter geblacklisted!\nBlackliste welche mit !imgblacklist add [Wort]"
 | 
			
		||||
  else
 | 
			
		||||
    local sort_alph = function( a,b ) return a < b end
 | 
			
		||||
    table.sort( _blacklist, sort_alph )
 | 
			
		||||
    local blacklist = "Folgende Wörter stehen auf der Blacklist:\n"
 | 
			
		||||
    for v,word in pairs(_blacklist) do
 | 
			
		||||
      blacklist = blacklist..'- '..word..'\n'
 | 
			
		||||
    end
 | 
			
		||||
	return blacklist
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function cache_nsfw_image(results, text)
 | 
			
		||||
  local cache = {}
 | 
			
		||||
  for v in pairs(results) do
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user