Advertisement
Terrah

blacklist

Dec 31st, 2015
551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. local old = MOD.EventMsg;
  2. MOD.BanCount = MOD.BanCount or 0;
  3. MOD.LastBanned = MOD.LastBanned or "nobody!";
  4. local UserCache = {};
  5.  
  6. if type(MOD.BlackList) ~= "table" then
  7. MOD.BlackList = {};
  8. end
  9.  
  10. local function IsOnList(msg)
  11.  
  12. msg = msg:lower();
  13. local word;
  14.  
  15. for k,v in pairs(MOD.BlackList) do
  16.  
  17. word = tostring(v):lower()
  18.  
  19. if msg:find(word, 1, true) then
  20. return true;
  21. end
  22. end
  23.  
  24. return false;
  25. end
  26.  
  27. local function BlackListed(usr,msg)
  28.  
  29. if msg==nil or msg=="" then
  30. return false;
  31. end
  32.  
  33. local ok = UserCache[usr];
  34.  
  35. if ok==nil then
  36. ok = MOD.GetVar(usr,Channel());
  37. end
  38.  
  39. if ok then
  40. return false;
  41. elseif IsOnList(msg) then
  42. return true;
  43. else
  44. MOD.SetVar(usr,true,"users");
  45. UserCache[usr]=true;
  46. return false;
  47. end
  48. end
  49.  
  50. MOD.EventMsg = function(usr,msg)
  51.  
  52. if BlackListed(usr,msg) then
  53. MOD.Ban(usr);
  54. MOD.BanCount = MOD.BanCount + 1;
  55. MOD.LastBanned = usr;
  56. MOD.Save();
  57. end
  58.  
  59. if type(old) == "function" then
  60. return old(usr,msg);
  61. end
  62. end
  63.  
  64. return function(msg,usr,chan)
  65. print("Banned "..tostring(MOD.BanCount).." things. Last one was "..tostring(MOD.LastBanned));
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement