Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ChatBlockDB = {}
- local function Say(msg)
- DEFAULT_CHAT_FRAME:AddMessage("|cFFFF8300ChatBlock:|r".." ".."|cFF25DCE0"..msg.."|r")
- end
- function table.contains(table, word)
- for k, v in pairs(table) do
- if v == word then
- return true
- end
- end
- return false
- end
- function table.wipe(table)
- for k, v in pairs(table) do
- (table)[k] = nil
- end
- end
- function HideIt(message)
- if message ~= nil then
- local msgLower = string.lower(message)
- for k, v in pairs(ChatBlockDB) do
- if msgLower:match(v) then
- return true
- end
- end
- end
- end
- ChatFrame_AddMessageEventFilter("CHAT_MSG_CHANNEL", HideIt)
- SLASH_CB1 = "/cb"
- SlashCmdList["CB"] = function(msg, editbox)
- local command, rest = msg:match("^(%S*)%s*(.-)$")
- if command == "add" and rest ~= "" then
- if table.contains(ChatBlockDB, rest) then
- Say('The word "' ..rest.. '" already exists in the DataBase!')
- else
- table.insert(ChatBlockDB, rest)
- Say('The word "' ..rest.. '" has been added to the DataBase!')
- end
- elseif command == "remove" and rest ~= "" then
- if table.contains(ChatBlockDB, rest) then
- for k, v in pairs(ChatBlockDB) do
- if v == rest then
- table.remove(ChatBlockDB, k)
- Say('The word "' ..rest.. '" has been removed from the DataBase!')
- end
- end
- else
- Say('The word "' ..rest.. '" does not exist in the DataBase!')
- end
- elseif command == "list" and rest == "" then
- if #ChatBlockDB > 0 then
- for k, v in pairs(ChatBlockDB) do
- Say(v)
- end
- else
- Say('No words have been added to the DataBase yet!')
- end
- elseif command == "wipe" and rest == "" then
- if #ChatBlockDB > 0 then
- table.wipe(ChatBlockDB)
- Say('The DataBase has been cleared!')
- else
- Say('No words have been added to the DataBase yet!')
- end
- elseif command == "help" and rest == "" then
- Say('Syntax: /cb add/remove "word" (add/removes a word from the list.)')
- Say('Syntax: /cb list (Shows a list of currently blocked words.)')
- Say('Syntax: /cb wipe (Removes all words from the DataBase.)')
- else
- Say('Syntax: /cb help (For a list of options.)')
- end
- end
- Say('by "Genericmage" loaded!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement