--Ban-4X-Kick 1.0 -- --by Mutor 7/16/04 -- --Auto bans a user on 'x' times kicked. [+1] :) -- -- Provides option for: -- - Report to Admin, Ops or Main -- - Set number of kicks before ban -- - send user website/forum message -- - loads/saves kicks to external files -- files(s) when hub/scripts restart -- -- Local Ops now exempt -- --User Settings------------------------------------------------------------------------------------- --Number of time a user may be kicked, user will be banned at next login. kickcount = 5 --Send report to main chat Snd2All = "0" --Send pm report to ops Snd2Ops = "1" -- 1 = on / 0 = off --Send pm report Admin's Nick Snd2Admin = "0" --Admin's Nick or any other single nick AdminName = "Mutor" --Name for bot [You can use your main bot, if so no need to register this bot. See 'function main'. Bot = "[Sentry]" --End User Settings---------------------------------------------------------------------------------- -- Kicked = {} KickFile = "Kicks.txt" function Main() --frmHub:RegBot(Bot) --If using main bot, remark this line, add -- ie.. --frmHub:RegBot(Bot) frmHub:EnableFullData(1) LoadFromFile(KickFile) end function NewUserConnected(user, data) if Kicked[user.sName]==kickcount then Kicked[user.sName]=nil local Report2 Report2 = "\r\n\r\n\t---<>-------------------------------------------------------<>--- \r\n" Report2 = Report2.."\tThe user "..user.sName.." has been kicked [ "..kickcount.." ] times.\r\n" Report2 = Report2.."\t"..user.sName.." attempted login and has been banned. \r\n" Report2 = Report2.."\t---<>-------------------------------------------------------<>--- \r\n" if Snd2Admin == "1" then SendPmToNick(AdminName,Bot,Report2) end if Snd2Ops == "1" then SendPmToOps(Bot,Report2) end if Snd2All == "1" then SendToAll(Bot,Report2) end local BanMsg BanMsg = "\r\n\r\n\t---<>----------------------------------------------------------------<>---\r\n" BanMsg = BanMsg.."\tYou had been kicked [ "..kickcount.." ] times, now your banned. \r\n" BanMsg = BanMsg.."\tIf you disagree with your ban. Visit our forum at : \r\n\r\n" BanMsg = BanMsg.."\t\thttp://hubforum.no-ip.com \r\n" BanMsg = BanMsg.."\t---<>----------------------------------------------------------------<>---\r\n" user:SendData(Bot, BanMsg) user:SendPM(Bot, BanMsg) user:Ban() end end function DataArrival(user, data) data=strsub(data,1,-2) _,_,cmd,unick = strfind( data, "(%S+)%s+(%S+)" ) if cmd == "$Kick" and user.bOperator then if Kicked[unick]==nil then Kicked[unick]=1 elseif Kicked[unick]~= nil then Kicked[unick] = Kicked[unick]+1 if Kicked[unick]== kickcount then local Report1 Report1 = "\r\n\r\n\t---<>-------------------------------------------------------<>---\r\n" Report1 = Report1.."\tThe user "..unick.." has been kicked [ "..kickcount.." ] times.\r\n" Report1 = Report1.."\t"..unick.." will be banned at next login to this hub.\r\n" Report1 = Report1.."\t---<>-------------------------------------------------------<>---\r\n" if Snd2Admin == "1" then SendPmToNick(AdminName,Bot,Report2) end if Snd2Ops == "1" then SendPmToOps(Bot,Report2) end if Snd2All == "1" then SendToAll(Bot,Report2) end end end end end function OnExit() SaveToFile(KickFile , Kicked , "Kicked") end function Serialize(tTable, sTableName, sTab) assert(tTable, "tTable equals nil"); assert(sTableName, "sTableName equals nil"); assert(type(tTable) == "table", "tTable must be a table!"); assert(type(sTableName) == "string", "sTableName must be a string!"); sTab = sTab or ""; sTmp = "" sTmp = sTmp..sTab..sTableName.." = {\n" for key, value in tTable do local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key); if(type(value) == "table") then sTmp = sTmp..Serialize(value, sKey, sTab.."\t"); else local sValue = (type(value) == "string") and format("%q",value) or tostring(value); sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue end sTmp = sTmp..",\n" end sTmp = sTmp..sTab.."}" return sTmp end function SaveToFile(file , table , tablename) writeto(file) write(Serialize(table, tablename)) writeto() end function LoadFromFile(file) if (readfrom(file) ~= nil) then readfrom(file) dostring(read("*all")) readfrom() end end