-- SearchSentry 1.01c -- by Mutor The Ugly -- -- Monitors user searches for unwanted queries. -- Provides option for: -- - warn [warned 3 times = ban] -- - timeban [timeban 3 times = ban] -- - send user website/forum message -- - loads/saves warns to external files -- files(s) saved before hub/scripts restart -- - send report to admin -- - send report to operators -- - send report to main chat -- -- Local Ops now exempt... -- --User Settings------------------------------------------------------------------------------------- --Send report to main chat Snd2All = "1" --Send pm report to ops Snd2Ops = "0" -- 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]" -- Message to direct user to hubs website or forum ForumMsg = "\r\n\r\n\tIf you disagree and would like to be unbanned. Visit our forum at : \r\n\r\n\t\t http://hubforum.no-ip.com \r\n\r\n\t\t\t\tand state your case." --Minutes to be banned for on first ban offense Firstx = "5" --Minutes to be banned on second ban offense Secondx = "15" --Minutes to be banned on third ban offense Thirdx = "30" --File(s) to save warn data WarnFile = "Warned.txt" BanWarnFile = "BanWarned.txt" -- -- Bad filenames, use caution to avoid kicking/banning for harmless filenames that may include these words. trigs = { ["stealthdc"] ="Warn", ["r@ygold"] ="Warn", ["animalsex"] ="Warn", ["beastiality"] ="Warn", ["lolita"] ="Warn", ["preteen"] ="Ban", ["incest"] ="Ban", ["rape"] ="Ban", ["underage"] ="Ban", ["childsex"] ="Ban", ["childporn"] ="Ban" } --End User Settings---------------------------------------------------------------------------------- Warned = {} BanWarned = {} function Main() --frmHub:RegBot(Bot) --If using main bot, remark this line, add -- ie.. --frmHub:RegBot(sBot) frmHub:EnableSearchData(1) LoadFromFile(WarnFile) LoadFromFile(BanWarnFile) end function DataArrival(user, data) if ((strlower(strsub(data,1,3))=="$sr")or(strlower(strsub(data,1,7))=="$search")) and not user.bOperator then BanTime = "" BanUser = "" DisconnectUser = "" xwarned = "3, User Now Banned" for key, value in trigs do if( strfind( strlower(data), key) ) then if value == "Warn" then DisconnectUser = "1" if Warned[user.sName]==nil then Warned[user.sName]=1 xwarned = "First Warning" Offense = "Warned User" elseif Warned[user.sName]==1 then Warned[user.sName]=2 xwarned = "Second Warning" Offense = "Warned User" elseif Warned[user.sName]==2 then Warned[user.sName]=3 xwarned = "Third & Final, Ban Next" Offense = "Warned User" elseif Warned[user.sName]==3 then Warned[user.sName]=nil Warned3x = "1" Offense = "User Is Banned" DisconnectUser = "" end elseif value == "Ban" then if BanWarned[user.sName]==nil then BanWarned[user.sName]=1 xwarned = "First Warning" Offense = "Warned & TimeBanned" BanWarned3x = "1" BanTime = Firstx elseif BanWarned[user.sName]==1 then BanWarned[user.sName]=2 xwarned = "Second Warning" Offense = "Warned & TimeBanned" BanWarned3x = "1" BanTime = Secondx elseif BanWarned[user.sName]==2 then BanWarned[user.sName]=3 xwarned = "Third & Final, Ban Next" Offense = "Warned & TimeBanned" BanWarned3x = "1" BanTime = Thirdx elseif BanWarned[user.sName]==3 then BanWarned[user.sName]=nil Warned3x = "1" Offense = "User is banned" end end AReport = "\r\n\r\n\t -<> Administrators Report <>-\r\n\t[ ]----------------------------------------------------[ ]" Report = "\r\n\r\n\t[ Unacceptable Search Detected ]\r\n\r\n\tUsers Name :\t"..user.sName.."\r\n\tSearch From :\t"..user.sIP..".\r\n\tSearch String :\t"..key.."\r\n\tResponse :\t "..Offense.."\r\n\tTimes Warned :\t[ "..xwarned.." ]\r\n\r\n" WarnMsg = "\r\n\r\n\tYour search conflicts with this hub's policies\r\n\tTimes warned: [ "..xwarned.." ]\r\n\r\n\tUser Name:\t"..user.sName.."\r\n\tSearch From:\t"..user.sIP.."\r\n\tSearch String:\t"..key.."\r\n\r\n\tYou have been kicked!\r\n\r\n" BanWarnMsg = "\r\n\r\n\tYour search conflicts with this hub's policies\r\n\tTimes warned: [ "..xwarned.." ]\r\n\r\n\tUser Name:\t"..user.sName.."\r\n\tSearch From:\t"..user.sIP.."\r\n\tSearch String:\t"..key.."\r\n\r\n\tYou have been time banned for "..BanTime.." minutes.\r\n\r\n" BanMsg = "\r\n\r\n\tYour search conflicts with this hub's policies\r\n\r\n\tUser Name:\t"..user.sName.."\r\n\tSearch From:\t"..user.sIP.."\r\n\tSearch String:\t"..key.."\r\n\r\n\tYou have been banned!\r\n\r\n" if Snd2Admin == "1" then SendPmToNick(AdminName, Bot,AReport..Report ) end if Snd2All == "1" then SendToAll(Bot,Report ) end if Snd2Ops == "1" then SendPmToOps(Bot,Report ) end if DisconnectUser == "1" then SendPmToNick(user.sName, Bot, WarnMsg) user:Disconnect() DisconnectUser = "" end if BanWarned3x == "1" then SendPmToNick(user.sName, Bot, BanWarnMsg) user:TimeBan(BanTime) BanWarned3x = "" end if Warned3x == "1" then SendPmToNick(user.sName, Bot, BanMsg..ForumMsg) user:Ban() Warned3x = "" end if BanUser == "1" then SendPmToNick(user.sName, Bot, BanMsg..ForumMsg) user:Ban() BanUser = "" end end end end end function OnExit() SaveToFile(BanWarnFile , BanWarned , "BanWarned") SaveToFile(WarnFile , Warned , "Warned") 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"); -- The Bug was here 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.."}\r\n" 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