Advertisement
Guest User

ChatBlock

a guest
Jul 20th, 2021
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.27 KB | None | 0 0
  1. ChatBlockDB = {}
  2.  
  3. local function Say(msg)
  4.     DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8300ChatBlock:|r".." ".."|cFF25DCE0"..msg.."|r")
  5. end
  6.  
  7. function table.contains(table, word)
  8.     for k, v in pairs(table) do
  9.         if v == word then
  10.             return true
  11.         end
  12.     end
  13.     return false
  14. end
  15.  
  16. function table.wipe(table)
  17.     for k, v in pairs(table) do
  18.         (table)[k] = nil
  19.     end
  20. end
  21.  
  22. function HideIt(arg1, arg2, message)
  23.     if message ~= nil then
  24.         local msgLower = string.lower(message)
  25.         for k, v in pairs(ChatBlockDB) do
  26.             if msgLower:match(v) then
  27.                 return true
  28.             end
  29.         end
  30.     end
  31. end
  32.  
  33. ChatFrame_AddMessageEventFilter("CHAT_MSG_CHANNEL", HideIt)
  34.  
  35. SLASH_CB1 = "/cb"
  36. SlashCmdList["CB"] = function(msg, editbox)
  37.     local command, rest = msg:match("^(%S*)%s*(.-)$")
  38.     local rest2 = string.lower(rest)
  39.     if command == "add" and rest2 ~= "" then
  40.         if table.contains(ChatBlockDB, rest2) then
  41.             Say('The word "' ..rest2.. '" already exists in the DataBase!')
  42.         else
  43.             table.insert(ChatBlockDB, rest2)
  44.             Say('The word "' ..rest2.. '" has been added to the DataBase!')
  45.         end
  46.     elseif command == "remove" and rest2 ~= "" then
  47.         if table.contains(ChatBlockDB, rest2) then
  48.             for k, v in pairs(ChatBlockDB) do
  49.                 if v == rest2 then
  50.                     table.remove(ChatBlockDB, k)
  51.                     Say('The word "' ..rest2.. '" has been removed from the DataBase!')
  52.                 end
  53.             end
  54.         else
  55.             Say('The word "' ..rest2.. '" does not exist in the DataBase!')
  56.         end
  57.     elseif command == "list" and rest2 == "" then
  58.         if #ChatBlockDB > 0 then
  59.             for k, v in pairs(ChatBlockDB) do
  60.                 Say(v)
  61.             end
  62.         else
  63.             Say('No words have been added to the DataBase yet!')
  64.         end
  65.     elseif command == "wipe" and rest2 == "" then
  66.         if #ChatBlockDB > 0 then
  67.             table.wipe(ChatBlockDB)
  68.             Say('The DataBase has been cleared!')
  69.         else
  70.             Say('No words have been added to the DataBase yet!')
  71.         end
  72.     elseif command == "help" and rest2 == "" then
  73.         Say('Syntax: /cb add/remove "word" (add/removes a word from the list.)')
  74.         Say('Syntax: /cb list (Shows a list of currently blocked words.)')
  75.         Say('Syntax: /cb wipe (Removes all words from the DataBase.)')
  76.     else
  77.         Say('Syntax: /cb help (For a list of options.)')
  78.     end
  79. end
  80.  
  81. Say('for 3.3.5a by "Genericmage" loaded!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement