Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local old = MOD.EventMsg;
- MOD.BanCount = MOD.BanCount or 0;
- MOD.LastBanned = MOD.LastBanned or "nobody!";
- local UserCache = {};
- if type(MOD.BlackList) ~= "table" then
- MOD.BlackList = {};
- end
- local function IsOnList(msg)
- msg = msg:lower();
- local word;
- for k,v in pairs(MOD.BlackList) do
- word = tostring(v):lower()
- if msg:find(word, 1, true) then
- return true;
- end
- end
- return false;
- end
- local function BlackListed(usr,msg)
- if msg==nil or msg=="" then
- return false;
- end
- local ok = UserCache[usr];
- if ok==nil then
- ok = MOD.GetVar(usr,Channel());
- end
- if ok then
- return false;
- elseif IsOnList(msg) then
- return true;
- else
- MOD.SetVar(usr,true,"users");
- UserCache[usr]=true;
- return false;
- end
- end
- MOD.EventMsg = function(usr,msg)
- if BlackListed(usr,msg) then
- MOD.Ban(usr);
- MOD.BanCount = MOD.BanCount + 1;
- MOD.LastBanned = usr;
- MOD.Save();
- end
- if type(old) == "function" then
- return old(usr,msg);
- end
- end
- return function(msg,usr,chan)
- print("Banned "..tostring(MOD.BanCount).." things. Last one was "..tostring(MOD.LastBanned));
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement