'ChatSecurity script 1.0 by Gadget 'This script needs MODIFIED NMDC HUB SOFTWARE with PM's and/or main chat disabled. 'You can modify your hub with HubMod from http://gadget.no-ip.info or http://dc.ww-ei.com/files/Misc.%20DC 'If main chat messages appear after other script replies, try to get this script first on the script host list Dim sCensorWords,sMuteInMain,sMuteInFirstPM,sMuteInPMs,sMuteUsers,iLoginTimeout,iViolationTimeout,iMaxMsgs,iMsgsToKick,iMaxMsgLength Dim bHandlePMs,bHandleMain,bBlockAllPMs,bBlockMain,bDisableSecurity,bMeCommand,bCheckOrigin,sAdmins,oMsgTo,oMsgCount,oMsgTime,iTicker,sLastKicked Sub Main() 'Settings are non-case-sensitive and they wont affect messages sent by ops or to another scripts sCensorWords = "geocities.com/dcfakepatch|dcfakepatch|dcfake|.to|www.outwar.com|outwar.com|outwar" 'Words with these strings will be replaced with asterisks, ""=Disabled sMuteInMain = "outwar|dcfake" 'Sentences with any these strings will not be shown in main chat and user will be temporarily muted, ""=Disabled sMuteInFirstPM = "slot|fuck|.com|.org|.net|dchub|%USERNAME%|dyndns|no-ip|.to" 'If first private message sent to user contains any of these words, message will not be delivered and user will be temporarily muted, ""=Disabled sMuteInPMs = "dcspam|d c s p a m|dcfake|outwar" 'If any of private messages sent to user contains any of these words, message will not be delivered, ""=Disabled sMuteUsers = "" 'All messages to or from these users will not be delivered (except if op sends a PM), you can use IP's here too, ""=Disabled iLoginTimeout = 0 'Timeout in minutes before user can send any messages after logging in to hub, 0=disabled iViolationTimeout = 2 'Timeout in minutes before user can send any messages after any violations, 0=disabled iMaxMsgs = 50 'Maximum number of messages users can send in one minute, 0=disabled iMsgsToKick = 75 'If user sends more messages than in this in one minute, he will be kicked, 0=disabled iMaxMsgLength = 0 'Maximum length of message, 0=disabled bHandlePMs = True 'True if you modified your hub software and disabled PM's, otherwise False bHandleMain = True 'True if you modified your hub software and disabled main chat, otherwise False bBlockAllPMs = False 'True if you want to disable all PM's from all users (except ops), otherwise False bBlockMain = False 'True if you want to disable whole main chat from all users (except ops), otherwise False bDisableSecurity = False 'True if you want to disable this script so all users can chat without restrictions, otherwise False bMeCommand = True 'Allows usage of irc-style !me command in main chat and PM's bCheckOrigin = True 'If True, compares message sender to reported sender in message and kicks if they dont match, otherwise False sAdmins = "All" 'Oplist where who can control the script 'Use "All" to include all of the ops, "" to include no-one, or "operator1|operator2" etc. Set oMsgTo = CreateObject("Scripting.Dictionary") Set oMsgCount = CreateObject("Scripting.Dictionary") Set oMsgTime = CreateObject("Scripting.Dictionary") tmrScriptTimer.Interval = 60000 tmrScriptTimer.Enabled = True End Sub Sub tmrScriptTimer_Timer() oMsgCount.RemoveAll sLastKicked="" iTicker=iTicker+1 If iTicker>60 Then oMsgTo.RemoveAll End If End Sub Sub NewUserConnected(curUser) oMsgTime(curUser.IP)=DateAdd("n",iLoginTimeout,Now) End Sub Sub DataArival (curUser,sCurData) If Left(sCurData,1)="<" And bHandleMain Then On Error Resume Next sMessage=Mid(sCurData,InStr(sCurData,">")+2) sSender=Mid(sCurData,2,InStr(sCurData,">")-2) If Not curUser.bOperator And Not bDisableSecurity Then oMsgCount(curUser.IP)=1+oMsgCount(curUser.IP) If (sSender<>curUser.sName Or curUser.sMyInfoString="") And bCheckOrigin Then Call KickUser(curUser,"Hacking attempt") Exit Sub End If If oMsgCount(curUser.IP)=iMaxMsgs And iMaxMsgs>0 Then curUser.SendData " Warning: You are sending over "+cStr(iMaxMsgs)+" messages in minute.|" ElseIf oMsgCount(curUser.IP)=iMaxMsgs+1 And iMaxMsgs>0 Then colUsers.SendToAll CStr(" The user "+curUser.sName+" is muted for "+CStr(iViolationTimeout)+" minutes because of flooding the chat.|") curUser.SendData " You are sending too much messages. You are muted for "+CStr(iViolationTimeout)+" minutes.|" oMsgTime(curUser.IP)=DateAdd("n",iViolationTimeout,Now) Exit Sub ElseIf oMsgCount(curUser.IP)>iMsgsToKick And iMsgsToKick>0 Then Call KickUser(curUser,"Trying to flood the chat") Exit Sub End If If bBlockMain Then curUser.SendData " Main chat is off. Your message has not been sent.|" Exit Sub End If If InStr("|"+LCase(sMuteUsers)+"|","|"+LCase(curUser.sName)+"|")>0 Or InStr("|"+sMuteUsers+"|","|"+curUser.IP+"|")>0 Then curUser.SendData " You are muted. Your message has not been sent.|" Exit Sub End If If oMsgTime.Exists(curUser.IP) Then If DateDiff("n",Now,oMsgTime(curUser.IP))>0 Then curUser.SendData " You are muted for "+CStr(DateDiff("n",Now,oMsgTime(curUser.IP)))+" minutes. Your message has not been sent.|" Exit Sub Else oMsgTime.Remove(curUser.IP) End If End If If Len(sMessage)>iMaxMsgLength And iMaxMsgLength>0 Then curUser.SendData " Your message was too long and it has not been sent.|" Exit Sub End If aMuteInMain=Split(sMuteInMain,"|") For i=0 To UBound(aMuteInMain) If InStr(LCase(sMessage),LCase(aMuteInMain(i)))>0 And aMuteInMain(i)<>"" Then If iViolationTimeout>0 Then curUser.SendData " Bad message. You are muted for "+CStr(iViolationTimeout)+" minutes. NOW SHUT-UP!|" colUsers.SendToAll CStr(" The user "+curUser.sName+" is muted for "+CStr(iViolationTimeout)+" minutes because abusing the main chat.|") oMsgTime(curUser.IP)=DateAdd("n",iViolationTimeout,Now) Exit Sub Else curUser.SendData " Bad message. Your message has not been sent.|" Exit Sub End If End If Next aCensorWords=Split(sCensorWords,"|") For i=0 To UBound(aCensorWords) If aCensorWords(i)<>"" Then sMessage=Replace(sMessage,aCensorWords(i),String(Len(aCensorWords(i)),"*"),1,-1,1) End If Next End If If sMessage<>"" Then If LCase(Left(sMessage,4))="!me " And bMeCommand Then colUsers.SendToAll CStr("* "+curUser.sName+" "+Mid(sMessage,5)) Else colUsers.SendChatToAll cStr(curUser.sName),cStr(sMessage) End If If Left(sMessage,1)="!" And curUser.bOperator And sAdmins<>"" Then If LCase(sAdmins)="all" Or InStr("|"+LCase(sAdmins)+"|","|"+LCase(curUser.sName)+"|")>0 Then sReply="" sArg="" iTime=-1 aCmd=Split(Mid(sMessage,2)," ") If UBound(aCmd)>0 Then sArg=aCmd(1) If UBound(aCmd)>1 Then iTime=CDbl(aCmd(2)) Select Case LCase(aCmd(0)) Case "help" sReply="@Chat control commands:"+_ vbCrLf+"!mainchat [on/off]"+vbTab+vbTab+"Sets main chat on or off (currently "+sValue(bBlockmain)+")"+_ vbCrLf+"!pmchat [on/off]"+vbTab+vbTab+"Sets private messaging on or off (currently "+sValue(bBlockAllPMs)+")"+_ vbCrLf+"!chatcontrol [on/off]"+vbTab+vbTab+"Sets chat restrictions on or off (currently "+sValue(bDisableSecurity)+")"+_ vbCrLf+"!mute [time]"+vbTab+vbTab+"Mutes an user"+_ vbCrLf+"!unmute "+vbTab+vbTab+"Unmutes an user"+_ vbCrLf+"!clearmutes"+vbTab+vbTab+"Unmutes all users"+_ vbCrLf+"!censor "+vbTab+vbTab+"Censorizes a word so it will be replaced with asterisks in chat"+_ vbCrLf+"!uncensor "+vbTab+vbTab+"Uncensorizes a word"+_ vbCrLf+"!banword "+vbTab+vbTab+"Bans a word so users who use it will get muted"+_ vbCrLf+"!unbanword "+vbTab+vbTab+"Unbans a word"+_ vbCrLf+"!addadmin "+vbTab+vbTab+"Adds an admin who can control the chat"+_ vbCrLf+"!removeadmin "+vbTab+"Removes admin rights"+_ vbCrLf+"!set logintimeout "+vbTab+"Sets timeout after login before users can chat (currently "+CStr(iLoginTimeout)+" minutes)"+_ vbCrLf+"!set violationtimeout "+vbTab+"Sets timeout on violation cases (currently "+CStr(iViolationTimeout)+" minutes)"+_ vbCrLf+"!set maxmessages "+vbTab+"Sets maximum number of messages before muting (currently "+CStr(iMaxMsgs)+" messages/minute)"+_ vbCrLf+"!set messagestokick "+vbTab+"Sets maximum number of messages before kicking (currently "+CStr(iMsgsToKick)+" messages/minute)"+_ vbCrLf+"!set maxlength "+vbTab+"Sets maximum message length (currently "+CStr(iMaxMsgLength)+" characters)"+_ vbCrLf+"!help"+vbTab+vbTab+vbTab+"Shows this help" Case "mainchat" If LCase(sArg)="on" Then bBlockMain=False ElseIf LCase(sArg)="off" Then bBlockMain=True End If sReply="Main chat is "+sValue(bBlockmain)+"." Case "privatechat","pmchat" If LCase(sArg)="on" Then bBlockAllPMs=False ElseIf LCase(sArg)="off" Then bBlockAllPMs=True End If sReply="Main chat is "+sValue(bBlockAllPMs)+"." Case "chatcontrol" If LCase(sArg)="on" Then bDisableSecurity=False ElseIf LCase(sArg)="off" Then bDisableSecurity=True End If sReply="Chat control is "+sValue(bBlockAllPMs)+"." Case "mute" If sArg="" Then sReply="Please give a username" ElseIf Not colUsers.Online(CStr(sArg)) Then sReply="Can't mute because user "+sArg+" is not online." Else If iTime<1 Then iTime=iViolationTimeout sReply="The user "+sArg+" is muted for "+CStr(iTime)+" minutes." oMsgTime(colUsers.ItemByName(CStr(sArg)).IP)=DateAdd("n",iTime,Now) End If Case "unmute" If sArg="" Then sReply="Please give a username" ElseIf Not colUsers.Online(CStr(sArg)) Then sReply="Can't unmute because user "+sArg+" is not online." Else If oMsgTime.Exists(colUsers.ItemByName(CStr(sArg)).IP) Then oMsgTime.Remove(colUsers.ItemByName(CStr(sArg)).IP) If oMsgTo.Exists(colUsers.ItemByName(CStr(sArg)).IP) Then oMsgTo.Remove(colUsers.ItemByName(CStr(sArg)).IP) If oMsgCount.Exists(colUsers.ItemByName(CStr(sArg)).IP) Then oMsgCount.Remove(colUsers.ItemByName(CStr(sArg)).IP) sReply="The user "+sArg+" can chat again." Else sReply="The user "+sArg+" is not muted." End If End If Case "clearmutes" oMsgCount.RemoveAll oMsgTo.RemoveAll oMsgTime.RemoveAll sReply="All muted users can talk again now." Case "censor" sCensorWords=sAddValue(sCensorWords,sArg) If sCensorWords="" Then sReply="@There are no censored words" Else sReply="@Censored words: '"+Replace(sCensorWords,"|","', '")+"'." End If Case "uncensor" sCensorWords=sRemoveValue(sCensorWords,sArg) If sCensorWords="" Then sReply="@There are no censored words" Else sReply="@Censored words: '"+Replace(sCensorWords,"|","', '")+"'." End If Case "banword" sMuteInMain=sAddValue(sMuteInMain,sArg) If sMuteInMain="" Then sReply="@There are no banned words" Else sReply="@Banned words: '"+Replace(sMuteInMain,"|","', '")+"'." End If Case "unbanword" sMuteInMain=sRemoveValue(sMuteInMain,sArg) If sMuteInMain="" Then sReply="@There are no banned words" Else sReply="@Banned words: '"+Replace(sMuteInMain,"|","', '")+"'." End If Case "addadmin" If LCase(sAdmins)="all" Then sReply="@All operators are chat admins." Else sAdmins=sAddValue(sAdmins,sArg) If sAdmins="" Then sReply="@There are no chat admins." Else sReply="@Chat admins: '"+Replace(sAdmins,"|","', '")+"'." End If End If Case "removeadmin" If LCase(sAdmins)="all" Then sReply="@Can't remove because all operators are set as chat admins, contact the hubowner." Else sAdmins=sRemoveValue(sAdmins,sArg) If sAdmins="" Then sReply="@There are no chat admins." Else sReply="@Chat admins: '"+Replace(sAdmins,"|","', '")+"'." End If End If Case "set" If iTime>-1 Then Select Case LCase(sArg) Case "logintimeout" iLoginTimeout=iTime sReply="Login timeout is set to "+CStr(iLoginTimeout)+" minutes." Case "violationtimeout" iViolationTimeout=iTime sReply="Violation timeout is set to "+CStr(iViolationTimeout)+" minutes." Case "maxmessages" iMaxMsgs=iTime sReply="Maximum messages per minute is set to "+CStr(iMaxMsgs)+"." Case "messagestokick" iMsgsToKick=iTime sReply="Maximum messages per minute before kicking is set to "+CStr(iMsgsToKick)+"." Case "maxlength" iMaxMsgLength=iTime sReply="Maximum message length is set to "+CStr(iMaxMsgLength)+"." End Select Else sReply="Argument is not valid" End If End Select If sReply<>"" Then If Left(sReply,1)="@" Then curUser.SendData cStr(" "+Mid(sReply,2)+"|") Else colUsers.SendToAll cStr(" "+sReply+"|") End If End If End If End If End If End If If Left(sCurData,5)="$To: " And bHandlePMs Then sMessage=Mid(sCurData,InStr(sCurData,">")+2) sReceiver=CStr(Mid(sCurData,6,InStr(6,CStr(sCurData)," ")-6)) sSender=Mid(sCurData,InStr(sCurData,"From: ")+6) sSender=Left(sSender,InStr(sSender," $")-1) sSender2=Mid(sCurData,InStr(sCurData,"$<")+2) sSender2=Left(sSender2,InStr(sSender2,">")-1) If Not curUser.bOperator And Not bDisableSecurity Then oMsgCount(curUser.IP)=1+oMsgCount(curUser.IP) If (sSender<>curUser.sName Or sSender2<>curUser.sName Or curUser.sMyInfoString="") And bCheckOrigin Then Call KickUser(curUser,"Hacking attempt") Exit Sub End If If oMsgCount(curUser.IP)=iMaxMsgs And iMaxMsgs>0 Then curUser.SendData CStr("$To: "+sSender+" From: "+sReceiver+" $ Warning: You are sending over "+cStr(iMaxMsgs)+" messages in minute.|") ElseIf oMsgCount(curUser.IP)=iMaxMsgs+1 And iMaxMsgs>0 Then curUser.SendData CStr("$To: "+sSender+" From: "+sReceiver+" $ You are muted for "+CStr(iViolationTimeout)+" minutes because of PM flood.|") colUsers.SendToAll CStr(" The user "+curUser.sName+" is muted for "+CStr(iViolationTimeout)+" minutes because of PM flood.|") oMsgTime(curUser.IP)=DateAdd("n",iViolationTimeout,Now) Exit Sub ElseIf oMsgCount(curUser.IP)>iMsgsToKick And iMsgsToKick>0 Then Call KickUser(curUser,"Flooding with PMs") Exit Sub End If If bBlockAllPMs Then curUser.SendData CStr("$To: "+sSender+" From: "+sReceiver+" $ Private messages are off. Your message has not been sent.|") Exit Sub End If If InStr("|"+LCase(sMuteUsers)+"|","|"+LCase(curUser.sName)+"|")>0 Or InStr("|"+sMuteUsers+"|","|"+curUser.IP+"|")>0 Then curUser.SendData CStr("$To: "+sSender+" From: "+sReceiver+" $ You are muted. Your message has not been sent.|") Exit Sub End If If InStr("|"+LCase(sMuteUsers)+"|","|"+LCase(sReceiver)+"|")>0 Then curUser.SendData CStr("$To: "+sSender+" From: "+sReceiver+" $ You are trying to send a message to user which is muted. Your message has not been sent.|") Exit Sub End If If oMsgTime.Exists(curUser.IP) Then If DateDiff("n",Now,oMsgTime(curUser.IP))>0 Then curUser.SendData CStr("$To: "+sSender+" From: "+sReceiver+" $ You are muted for "+CStr(DateDiff("n",Now,oMsgTime(curUser.IP)))+" minutes. Your message has not been sent.|") Exit Sub Else oMsgTime.Remove(curUser.IP) End If End If If Not colUsers.Online(CStr(sReceiver)) Then Exit Sub If Len(sMessage)>iMaxMsgLength And iMaxMsgLength>0 Then curUser.SendData CStr("$To: "+sSender+" From: "+sReceiver+" $ Your message was too long and it has not been sent.|") Exit Sub End If If sReceiver<>oMsgTo(curUser.IP) Then aMuteInFirstPM=Split(sMuteInFirstPM,"|") For i=0 To UBound(aMuteInFirstPM) If (InStr(LCase(sMessage),LCase(aMuteInFirstPM(i)))>0 And aMuteInFirstPM(i)<>"") Or (aMuteInFirstPM(i)="%USERNAME%" And InStr(sMessage,sReceiver)>0) Then If iViolationTimeout>0 Then curUser.SendData CStr("$To: "+sSender+" From: "+sReceiver+" $ Bad message. You are muted for "+CStr(iViolationTimeout)+" minutes.|") colUsers.SendToAll CStr(" The user "+curUser.sName+" is muted for "+CStr(iViolationTimeout)+" minutes because of PM abusing.|") oMsgTime(curUser.IP)=DateAdd("n",iViolationTimeout,Now) Exit Sub Else curUser.SendData CStr("$To: "+sSender+" From: "+sReceiver+" $ Bad message. Your message has not been sent.|") Exit Sub End If End If Next oMsgTo(curUser.IP)=sReceiver End If aMuteInPMs=Split(sMuteInPMs,"|") For i=0 To UBound(aMuteInPMs) If InStr(LCase(sMessage),LCase(aMuteInPMs(i)))>0 And aMuteInPMs(i)<>"" Then curUser.SendData CStr("$To: "+sSender+" From: "+sReceiver+" $ Bad message. Your message has not been sent.|") Exit Sub End If Next aCensorWords=Split(sCensorWords,"|") For i=0 To UBound(aCensorWords) If aCensorWords(i)<>"" Then sMessage=Replace(sMessage,aCensorWords(i),String(Len(aCensorWords(i)),"*"),1,-1,1) End If Next End If If sMessage<>"" Then If LCase(Left(sMessage,4))="!me " And bMeCommand Then colUsers.ItemByName(CStr(sReceiver)).SendData CStr("$To: "+sReceiver+" From: "+sSender+" $* "+sSender+" "+Mid(sMessage,5)+"|") Else colUsers.ItemByName(CStr(sReceiver)).SendData CStr("$To: "+sReceiver+" From: "+sSender+" $<"+sSender+"> "+sMessage+"|") End If End If End If End Sub Sub KickUser(oUser,sReason) If sLastKicked=oUser.sName Then Exit Sub oUser.SendData CStr(" You are being kicked because: "+sReason) frmHub.DoEventsForMe colUsers.SendToAll CStr(" The user "+oUser.sName+" got kicked because: "+sReason+". IP: "+oUser.IP) oUser.Kick End Sub Function sValue(b) If b Then sValue="off" Else sValue="on" End If End Function Function sAddValue(sValues,sNewValue) If InStr(LCase("|"+sValues+"|"),LCase("|"+sNewValue+"|"))>0 Or sNewValue="" Then sAddValue=sValues Else sAddValue=sValues+"|"+sNewValue End If End Function Function sRemoveValue(sValues,sOldValue) sRemoveValue="" aValues=Split(sValues,"|") For i=0 To UBound(aValues) If LCase(aValues(i))<>LCase(sOldValue) And aValues(i)<>"" Then If sRemoveValue="" Then sRemoveValue=aValues(i) Else sRemoveValue=sRemoveValue+"|"+aValues(i) End If End If Next End Function