Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2021
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 45.15 KB | None | 0 0
  1. # netbots.tcl v4.10 (8 August 2005)
  2. # Copyright 1998-2005 by slennox
  3. # http://www.egghelp.org/
  4.  
  5. ## sentinel.tcl component script ##
  6.  
  7. proc sl_helpidx {hand chan idx} {
  8.   global sl_lockflags
  9.   if {![matchattr $hand m$sl_lockflags] && ![matchattr $hand |m$sl_lockflags $chan]} {return 0}
  10.   putidx $idx "sentinel.tcl commands"
  11.   if {[matchattr $hand m|m $chan]} {
  12.     putidx $idx " For channel masters:"
  13.     putidx $idx "  sentinel"
  14.   }
  15.   if {[matchattr $hand $sl_lockflags|$sl_lockflags $chan]} {
  16.     putidx $idx " For channel [nb_flag2word $sl_lockflags]:"
  17.     putidx $idx "  lock          unlock"
  18.   }
  19.   putidx $idx " "
  20.   return 1
  21. }
  22.  
  23. proc sl_help {hand chan idx cmd} {
  24.   global sl_lockflags
  25.   switch -exact -- $cmd {
  26.     "sentinel" {
  27.       if {[matchattr $hand m|m $chan]} {
  28.         putidx $idx "# sentinel"
  29.         putwrap $idx 3 "Displays current sentinel.tcl settings."
  30.         return 1
  31.       }
  32.     }
  33.     "lock" {
  34.       if {[matchattr $hand $sl_lockflags|$sl_lockflags $chan]} {
  35.         putidx $idx "# lock \[channel|-all\]"
  36.         putwrap $idx 3 "Locks the specified channel. If no channel is specified, locks the current console channel. If -all is specified, locks all channels bot is on."
  37.         return 1
  38.       }
  39.     }
  40.     "unlock" {
  41.       if {[matchattr $hand $sl_lockflags|$sl_lockflags $chan]} {
  42.         putidx $idx "# unlock \[channel|-all\]"
  43.         putwrap $idx 3 "Unlocks the specified channel. If no channel is specified, unlocks the current console channel. If -all is specified, unlocks all channels the bot is on."
  44.         return 1
  45.       }
  46.     }
  47.   }
  48.   return 0
  49. }
  50.  
  51. lappend nb_helpidx "sl_helpidx"
  52. set nb_help(sentinel) "sl_help"
  53. set nb_help(lock) "sl_help"
  54. set nb_help(unlock) "sl_help"
  55.  
  56. proc sl_ctcp {nick uhost hand dest key arg} {
  57.   global botnet-nick botnick realname sl_ban sl_bflooded sl_bcflood sl_bcqueue sl_bxjointime sl_bxmachine sl_bxonestack sl_bxsimul sl_bxsystem sl_bxversion sl_bxwhoami sl_ccbanhost sl_ccbannick sl_ccflood sl_ccqueue sl_flooded sl_locked sl_note
  58.   set chan [string tolower $dest]
  59.   if {[lsearch -exact $sl_ccflood 0] == -1 && [validchan $chan] && ![isop $nick $chan]} {
  60.     if {$nick == $botnick} {return 0}
  61.     if {$sl_ban && !$sl_locked($chan) && ![matchattr $hand f|f $chan]} {
  62.       lappend sl_ccbannick($chan) $nick ; lappend sl_ccbanhost($chan) [string tolower $uhost]
  63.       utimer [lindex $sl_ccflood 1] [list sl_ccbanqueue $chan]
  64.     }
  65.     if {$sl_flooded($chan)} {return 1}
  66.     incr sl_ccqueue($chan)
  67.     utimer [lindex $sl_ccflood 1] [list sl_ccqueuereset $chan]
  68.     if {$sl_ccqueue($chan) >= [lindex $sl_ccflood 0]} {
  69.       sl_lock $chan "CTCP flood" ${botnet-nick} ; return 1
  70.     }
  71.     if {$sl_bflooded} {return 1}
  72.   } elseif {[lindex $sl_bcflood 0] && $dest == $botnick} {
  73.     if {$sl_bflooded} {
  74.       sl_ignore [string tolower $uhost] $hand "CTCP flooder" ; return 1
  75.     }
  76.     incr sl_bcqueue
  77.     utimer [lindex $sl_bcflood 1] {incr sl_bcqueue -1}
  78.     if {$sl_bcqueue >= [lindex $sl_bcflood 0]} {
  79.       putlog "sentinel: CTCP flood detected on me! Stopped answering CTCPs temporarily."
  80.       set sl_bflooded 1
  81.       utimer [lindex $sl_bcflood 1] {set sl_bflooded 0}
  82.       if {[info commands sendnote] != ""} {
  83.         foreach recipient $sl_note {
  84.           if {[validuser $recipient]} {
  85.             sendnote SENTINEL $recipient "Bot was CTCP flooded."
  86.           }
  87.         }
  88.       }
  89.       nb_sendcmd * rbroadcast "sentinel: CTCP flood detected on me!"
  90.       return 1
  91.     }
  92.     if {$hand == "*"} {
  93.       nb_sendcmd * rbroadcast "CTCP from $nick!$uhost: $key [string range $arg 0 400]"
  94.     }
  95.   }
  96.  
  97.   if {!$sl_bxsimul} {return 0}
  98.   if {$sl_bxonestack} {return 1}
  99.   set sl_bxonestack 1 ; utimer 2 {set sl_bxonestack 0}
  100.   switch -exact -- $key {
  101.     "CLIENTINFO" {
  102.       set bxcmd [string toupper $arg]
  103.       switch -exact -- $bxcmd {
  104.         "" {putserv "NOTICE $nick :\001CLIENTINFO SED UTC ACTION DCC CDCC BDCC XDCC VERSION CLIENTINFO USERINFO ERRMSG FINGER TIME PING ECHO INVITE WHOAMI OP OPS UNBAN IDENT XLINK UPTIME  :Use CLIENTINFO <COMMAND> to get more specific information\001"}
  105.         "SED" {putserv "NOTICE $nick :\001CLIENTINFO SED contains simple_encrypted_data\001"}
  106.         "UTC" {putserv "NOTICE $nick :\001CLIENTINFO UTC substitutes the local timezone\001"}
  107.         "ACTION" {putserv "NOTICE $nick :\001CLIENTINFO ACTION contains action descriptions for atmosphere\001"}
  108.         "DCC" {putserv "NOTICE $nick :\001CLIENTINFO DCC requests a direct_client_connection\001"}
  109.         "CDCC" {putserv "NOTICE $nick :\001CLIENTINFO CDCC checks cdcc info for you\001"}
  110.         "BDCC" {putserv "NOTICE $nick :\001CLIENTINFO BDCC checks cdcc info for you\001"}
  111.         "XDCC" {putserv "NOTICE $nick :\001CLIENTINFO XDCC checks cdcc info for you\001"}
  112.         "VERSION" {putserv "NOTICE $nick :\001CLIENTINFO VERSION shows client type, version and environment\001"}
  113.         "CLIENTINFO" {putserv "NOTICE $nick :\001CLIENTINFO CLIENTINFO gives information about available CTCP commands\001"}
  114.         "USERINFO" {putserv "NOTICE $nick :\001CLIENTINFO USERINFO returns user settable information\001"}
  115.         "ERRMSG" {putserv "NOTICE $nick :\001CLIENTINFO ERRMSG returns error messages\001"}
  116.         "FINGER" {putserv "NOTICE $nick :\001CLIENTINFO FINGER shows real name, login name and idle time of user\001"}
  117.         "TIME" {putserv "NOTICE $nick :\001CLIENTINFO TIME tells you the time on the user's host\001"}
  118.         "PING" {putserv "NOTICE $nick :\001CLIENTINFO PING returns the arguments it receives\001"}
  119.         "ECHO" {putserv "NOTICE $nick :\001CLIENTINFO ECHO returns the arguments it receives\001"}
  120.         "INVITE" {putserv "NOTICE $nick :\001CLIENTINFO INVITE invite to channel specified\001"}
  121.         "WHOAMI" {putserv "NOTICE $nick :\001CLIENTINFO WHOAMI user list information\001"}
  122.         "OP" {putserv "NOTICE $nick :\001CLIENTINFO OP ops the person if on userlist\001"}
  123.         "OPS" {putserv "NOTICE $nick :\001CLIENTINFO OPS ops the person if on userlist\001"}
  124.         "UNBAN" {putserv "NOTICE $nick :\001CLIENTINFO UNBAN unbans the person from channel\001"}
  125.         "IDENT" {putserv "NOTICE $nick :\001CLIENTINFO IDENT change userhost of userlist\001"}
  126.         "XLINK" {putserv "NOTICE $nick :\001CLIENTINFO XLINK x-filez rule\001"}
  127.         "UPTIME" {putserv "NOTICE $nick :\001CLIENTINFO UPTIME my uptime\001"}
  128.         "default" {putserv "NOTICE $nick :\001ERRMSG CLIENTINFO: $arg is not a valid function\001"}
  129.       }
  130.       return 1
  131.     }
  132.     "VERSION" {
  133.       putserv "NOTICE $nick :\001VERSION \002BitchX-$sl_bxversion\002 by panasync \002-\002 $sl_bxsystem :\002 Keep it to yourself!\002\001"
  134.       return 1
  135.     }
  136.     "USERINFO" {
  137.       putserv "NOTICE $nick :\001USERINFO \001"
  138.       return 1
  139.     }
  140.     "FINGER" {
  141.       putserv "NOTICE $nick :\001FINGER $realname ($sl_bxwhoami@$sl_bxmachine) Idle [expr [unixtime] - $sl_bxjointime] seconds\001"
  142.       return 1
  143.     }
  144.     "PING" {
  145.       putserv "NOTICE $nick :\001PING $arg\001"
  146.       return 1
  147.     }
  148.     "ECHO" {
  149.       if {[validchan $chan]} {return 1}
  150.       putserv "NOTICE $nick :\001ECHO [string range $arg 0 59]\001"
  151.       return 1
  152.     }
  153.     "ERRMSG" {
  154.       if {[validchan $chan]} {return 1}
  155.       putserv "NOTICE $nick :\001ERRMSG [string range $arg 0 59]\001"
  156.       return 1
  157.     }
  158.     "INVITE" {
  159.       if {$arg == "" || [validchan $chan]} {return 1}
  160.       set chanarg [lindex [split $arg] 0]
  161.       if {((($sl_bxversion == "75p1+") && ([string trim [string index $chanarg 0] "#+&"] == "")) || (($sl_bxversion == "75p3+") && ([string trim [string index $chanarg 0] "#+&!"] == "")))} {
  162.         if {[validchan $chanarg]} {
  163.           putserv "NOTICE $nick :\002BitchX\002: Access Denied"
  164.         } else {
  165.           putserv "NOTICE $nick :\002BitchX\002: I'm not on that channel"
  166.         }
  167.       }
  168.       return 1
  169.     }
  170.     "WHOAMI" {
  171.       if {[validchan $chan]} {return 1}
  172.       putserv "NOTICE $nick :\002BitchX\002: Access Denied"
  173.       return 1
  174.     }
  175.     "OP" -
  176.     "OPS" {
  177.       if {$arg == "" || [validchan $chan]} {return 1}
  178.       putserv "NOTICE $nick :\002BitchX\002: I'm not on [lindex [split $arg] 0], or I'm not opped"
  179.       return 1
  180.     }
  181.     "UNBAN" {
  182.       if {$arg == "" || [validchan $chan]} {return 1}
  183.       if {[validchan [lindex [split $arg] 0]]} {
  184.         putserv "NOTICE $nick :\002BitchX\002: Access Denied"
  185.       } else {
  186.         putserv "NOTICE $nick :\002BitchX\002: I'm not on that channel"
  187.       }
  188.       return 1
  189.     }
  190.   }
  191.   return 0
  192. }
  193.  
  194. proc sl_bmflood {nick uhost hand text} {
  195.   global nb_castfilter sl_bmflood sl_bflooded sl_bmqueue sl_note
  196.   if {[matchattr $hand b] && [string tolower [lindex [split $text] 0]] == "go"} {return 0}
  197.   if {$sl_bflooded} {
  198.     sl_ignore [string tolower $uhost] $hand "MSG flooder" ; return 0
  199.   }
  200.   incr sl_bmqueue
  201.   utimer [lindex $sl_bmflood 1] {incr sl_bmqueue -1}
  202.   if {$sl_bmqueue >= [lindex $sl_bmflood 0]} {
  203.     putlog "sentinel: MSG flood detected on me! Stopped answering MSGs temporarily."
  204.     set sl_bflooded 1
  205.     utimer [lindex $sl_bmflood 1] {set sl_bflooded 0}
  206.     if {[info commands sendnote] != ""} {
  207.       foreach recipient $sl_note {
  208.         if {[validuser $recipient]} {
  209.           sendnote SENTINEL $recipient "Bot was MSG flooded."
  210.         }
  211.       }
  212.     }
  213.     nb_sendcmd * rbroadcast "sentinel: MSG flood detected on me!"
  214.     return 0
  215.   }
  216.   if {!$sl_bflooded && $hand == "*"} {
  217.     if {[lsearch -exact $nb_castfilter [string tolower [lindex [split $text] 0]]] != -1} {
  218.       nb_sendcmd * rbroadcast "MSG from $nick!$uhost: [lindex [split $text] 0] .."
  219.     } else {
  220.       nb_sendcmd * rbroadcast "MSG from $nick!$uhost: [string range $text 0 399]"
  221.     }
  222.   }
  223.   return 0
  224. }
  225.  
  226. proc sl_avflood {from keyword arg} {
  227.   global botnet-nick botnick sl_ban sl_avbanhost sl_avbannick sl_avflood sl_avqueue sl_flooded sl_locked sl_txflood sl_txqueue
  228.   set arg [split $arg]
  229.   set chan [string tolower [lindex $arg 0]]
  230.   if {![validchan $chan]} {return 0}
  231.   set nick [lindex [split $from !] 0]
  232.   if {$nick == $botnick || $nick == "" || [string match *.* $nick]} {return 0}
  233.   if {![onchan $nick $chan] || [isop $nick $chan]} {return 0}
  234.   if {!$sl_flooded($chan) && [lsearch -exact $sl_txflood 0] == -1} {
  235.     incr sl_txqueue($chan)
  236.     if {$sl_txqueue($chan) >= [lindex $sl_txflood 0]} {
  237.       sl_lock $chan "LINE flood" ${botnet-nick}
  238.     }
  239.   }
  240.   set text [join [lrange $arg 1 end]]
  241.   if {[string length [set floodtype [sl_checkaval $keyword $text]]] && [lsearch -exact $sl_avflood 0] == -1} {
  242.     set uhost [string trimleft [getchanhost $nick $chan] "~+-^="]
  243.     set hand [nick2hand $nick $chan]
  244.     if {$sl_ban && !$sl_locked($chan) && $nick != $botnick && ![matchattr $hand f|f $chan]} {
  245.       lappend sl_avbannick($chan) $nick ; lappend sl_avbanhost($chan) [string tolower $uhost]
  246.       utimer [lindex $sl_avflood 1] [list sl_avbanqueue $chan]
  247.     }
  248.     if {$sl_flooded($chan)} {return 0}
  249.     incr sl_avqueue($chan)
  250.     utimer [lindex $sl_avflood 1] [list sl_avqueuereset $chan]
  251.     if {$sl_avqueue($chan) >= [lindex $sl_avflood 0]} {
  252.       sl_lock $chan "TEXT ($floodtype) flood" ${botnet-nick}
  253.     }
  254.   }
  255.   return 0
  256. }
  257.  
  258. # proc now covers criteria for PRIVMSGs and NOTICEs
  259. proc sl_checkaval {keyword text} {
  260.   global sl_nclength sl_tsunami sl_txlength
  261.   if {$sl_txlength && [string equal $keyword "PRIVMSG"] && [string length $text] >= $sl_txlength} {
  262.     return "length"
  263.   }
  264.   if {$sl_nclength && [string equal $keyword "NOTICE"]} {
  265.     if {$sl_nclength == 1 || [string length $text] >= $sl_nclength} {
  266.       return "notice"
  267.     }
  268.   }
  269.   if {$sl_tsunami} {
  270.     if {[regsub -all -- "\001|\007" $text "" temp] >= 3} {
  271.       return "avalanche"
  272.     }
  273.     if {[regsub -all -- "\002|\003|\017|\026|\037" $text "" temp] >= $sl_tsunami} {
  274.       return "tsunami"
  275.     }
  276.   }
  277.   return ""
  278. }
  279.  
  280. proc sl_nkflood {nick uhost hand chan newnick} {
  281.   global botnet-nick botnick sl_ban sl_banmax sl_flooded sl_globalban sl_locked sl_nickkick sl_nkbanhost sl_nkflood sl_nkflooding sl_nkqueue
  282.   if {[string equal $chan "*"]} {return 0}
  283.   set chan [string tolower $chan]
  284.   if {[isop $newnick $chan]} {return 0}
  285.   if {$sl_ban && !$sl_locked($chan) && $nick != $botnick && ![matchattr $hand f|f $chan]} {
  286.     lappend sl_nkbanhost($chan) [string tolower $uhost]
  287.     utimer [lindex $sl_nkflood 1] [list sl_nkbanqueue $chan]
  288.   }
  289.   if {!$sl_nickkick && $sl_flooded($chan) && $sl_locked($chan)} {
  290.     putserv "KICK $chan $newnick :NICK flooder"
  291.     set sl_nickkick 1 ; set sl_nkflooding($chan) [unixtime]
  292.     if {$sl_ban} {
  293.       set bhost [string tolower [sl_masktype $uhost]]
  294.       if {$sl_globalban} {
  295.         if {[llength [banlist]] < $sl_banmax && ![isban $bhost] && ![matchban $bhost]} {
  296.           newban $bhost sentinel "NICK flooder" $sl_ban
  297.         }
  298.       } else {
  299.         if {[llength [banlist $chan]] < $sl_banmax && ![isban $bhost $chan] && ![matchban $bhost $chan]} {
  300.           newchanban $chan $bhost sentinel "NICK flooder" $sl_ban
  301.         }
  302.       }
  303.     }
  304.     utimer [expr [rand 2] + 3] {set sl_nickkick 0}
  305.     return 0
  306.   }
  307.   if {$sl_flooded($chan)} {return 0}
  308.   incr sl_nkqueue($chan)
  309.   utimer [lindex $sl_nkflood 1] [list sl_nkqueuereset $chan]
  310.   if {$sl_nkqueue($chan) >= [lindex $sl_nkflood 0]} {
  311.     sl_lock $chan "NICK flood" ${botnet-nick}
  312.   }
  313.   return 0
  314. }
  315.  
  316. proc sl_jflood {nick uhost hand chan} {
  317.   global botnet-nick botnick sl_ban sl_banmax sl_boban sl_bobanhost sl_bobannick sl_boflood sl_boqueue sl_flooded sl_globalban sl_jbanhost sl_jbannick sl_jflood sl_jqueue sl_locked sl_pqueue
  318.   if {$nick == $botnick} {
  319.     sl_setarray $chan
  320.   } else {
  321.     set ihost [string tolower [sl_masktype $uhost]]
  322.     if {[isignore $ihost]} {
  323.       killignore $ihost
  324.     }
  325.     set chan [string tolower $chan]
  326.     if {[lsearch -exact $sl_boflood 0] == -1 && [sl_checkbogus [lindex [split $uhost @] 0]]} {
  327.       if {!$sl_locked($chan) && ![matchattr $hand f|f $chan]} {
  328.         set bhost [string tolower [sl_masktype $uhost]]
  329.         if {$sl_boban && [botisop $chan] && !$sl_flooded($chan)} {
  330.           putserv "KICK $chan $nick :BOGUS username"
  331.           if {$sl_globalban} {
  332.             if {[llength [banlist]] < $sl_banmax && ![isban $bhost] && ![matchban $bhost]} {
  333.               newban $bhost sentinel "BOGUS username" $sl_boban
  334.             }
  335.           } else {
  336.             if {[llength [banlist $chan]] < $sl_banmax && ![isban $bhost $chan] && ![matchban $bhost $chan]} {
  337.               newchanban $chan $bhost sentinel "BOGUS username" $sl_boban
  338.             }
  339.           }
  340.         }
  341.         if {$sl_ban} {
  342.           lappend sl_bobannick($chan) $nick ; lappend sl_bobanhost($chan) [string tolower $uhost]
  343.           utimer [lindex $sl_boflood 1] [list sl_bobanqueue $chan]
  344.         }
  345.       }
  346.       if {!$sl_flooded($chan)} {
  347.         incr sl_boqueue($chan)
  348.         utimer [lindex $sl_boflood 1] [list sl_boqueuereset $chan]
  349.         if {$sl_boqueue($chan) >= [lindex $sl_boflood 0]} {
  350.           sl_lock $chan "BOGUS joins" ${botnet-nick}
  351.         }
  352.       }
  353.     }
  354.     if {[lsearch -exact $sl_jflood 0] == -1} {
  355.       if {$sl_ban && !$sl_locked($chan) && ![matchattr $hand f|f $chan]} {
  356.         lappend sl_jbannick($chan) $nick ; lappend sl_jbanhost($chan) [string tolower $uhost]
  357.         utimer [lindex $sl_jflood 1] [list sl_jbanqueue $chan]
  358.       }
  359.       if {$sl_flooded($chan)} {return 0}
  360.       incr sl_jqueue($chan)
  361.       utimer [lindex $sl_jflood 1] [list sl_jqueuereset $chan]
  362.       if {$sl_jqueue($chan) >= [lindex $sl_jflood 0] && $sl_pqueue($chan) >= [lindex $sl_jflood 0]} {
  363.         sl_lock $chan "JOIN-PART flood" ${botnet-nick}
  364.       }
  365.     }
  366.   }
  367.   return 0
  368. }
  369.  
  370. proc sl_checkbogus {ident} {
  371.   if {[regsub -all -- "\[^\041-\176\]" $ident "" temp] >= 1} {return 1}
  372.   return 0
  373. }
  374.  
  375. proc sl_pflood {nick uhost hand chan {msg ""}} {
  376.   global botnick sl_ban sl_flooded sl_jflood sl_locked sl_pbanhost sl_pbannick sl_pqueue
  377.   if {[lsearch -exact $sl_jflood 0] != -1} {return 0}
  378.   if {$nick == $botnick} {
  379.     if {![validchan $chan]} {
  380.       timer 5 [list sl_unsetarray $chan]
  381.     }
  382.     return 0
  383.   }
  384.   set chan [string tolower $chan]
  385.   if {$sl_ban && !$sl_locked($chan) && ![matchattr $hand f|f $chan]} {
  386.     lappend sl_pbannick($chan) $nick ; lappend sl_pbanhost($chan) [string tolower $uhost]
  387.     utimer [lindex $sl_jflood 1] [list sl_pbanqueue $chan]
  388.   }
  389.   if {$sl_flooded($chan)} {return 0}
  390.   incr sl_pqueue($chan)
  391.   utimer [lindex $sl_jflood 1] [list sl_pqueuereset $chan]
  392.   return 0
  393. }
  394.  
  395. proc sl_pfloodk {nick uhost hand chan kicked reason} {
  396.   global botnick sl_flooded sl_jflood sl_pqueue
  397.   if {[lsearch -exact $sl_jflood 0] != -1} {return 0}
  398.   if {$kicked == $botnick} {return 0}
  399.   set chan [string tolower $chan]
  400.   if {$sl_flooded($chan)} {return 0}
  401.   incr sl_pqueue($chan)
  402.   utimer [lindex $sl_jflood 1] [list sl_pqueuereset $chan]
  403.   return 0
  404. }
  405.  
  406. proc sl_lock {chan flood detected} {
  407.   global sl_bflooded sl_cfnotice sl_flooded sl_locktimes sl_note
  408.   if {[isbotnetnick $detected]} {
  409.     set sl_flooded($chan) 1 ; set sl_bflooded 1
  410.     if {[botisop $chan]} {
  411.       sl_quicklock $chan
  412.       nb_killutimer "sl_unlock $chan*"
  413.       nb_killutimer "set sl_bflooded 0"
  414.       foreach lockmode $sl_locktimes {
  415.         if {[lindex $lockmode 1]} {
  416.           utimer [lindex $lockmode 1] [list sl_unlock $chan [lindex $lockmode 0]]
  417.         }
  418.       }
  419.       utimer 120 {set sl_bflooded 0}
  420.       putlog "sentinel: $flood detected on $chan! Channel locked temporarily."
  421.       if {$sl_cfnotice != ""} {
  422.         puthelp "NOTICE $chan :$sl_cfnotice"
  423.       }
  424.     } else {
  425.       putlog "sentinel: $flood detected on $chan! Cannot lock channel because I'm not opped."
  426.       utimer 120 {set sl_bflooded 0}
  427.     }
  428.   } else {
  429.     putlog "sentinel: $flood detected by $detected on $chan!"
  430.   }
  431.   if {[info commands sendnote] != ""} {
  432.     foreach recipient $sl_note {
  433.       if {[validuser $recipient]} {
  434.         if {[isbotnetnick $detected]} {
  435.           sendnote SENTINEL $recipient "$flood detected on $chan."
  436.         } else {
  437.           sendnote SENTINEL $recipient "$flood detected by $detected on $chan."
  438.         }
  439.       }
  440.     }
  441.   }
  442.   if {[isbotnetnick $detected]} {
  443.     nb_sendcmd * rlock [list $chan $flood]
  444.   }
  445.   return 0
  446. }
  447.  
  448. proc nb_sl_lock {frombot arg} {
  449.   sl_lock [lindex $arg 0] [lindex $arg 1] $frombot
  450.   return 0
  451. }
  452.  
  453. proc sl_unlock {chan {umodes ""}} {
  454.   global sl_bflooded sl_bfmaxbans sl_flooded sl_locktimes sl_nkflooding
  455.   if {[expr [unixtime] - $sl_nkflooding($chan)] < 12} {
  456.     putlog "sentinel: nick flooding still in progress on $chan - not unlocking yet.."
  457.     set sl_flooded($chan) 1 ; set sl_bflooded 1
  458.     nb_killutimer "sl_unlock $chan*"
  459.     nb_killutimer "set sl_bflooded 0"
  460.     foreach lockmode $sl_locktimes {
  461.       if {[lindex $lockmode 1]} {
  462.         utimer [lindex $lockmode 1] [list sl_unlock $chan [lindex $lockmode 0]]
  463.       }
  464.     }
  465.     utimer 120 {set sl_bflooded 0}
  466.   } else {
  467.     set sl_flooded($chan) 0
  468.     if {![botisop $chan]} {return 0}
  469.     if {$umodes == ""} {
  470.       putlog "sentinel: flood was small, performing early unlock.."
  471.       set umodes [sl_lockmodes]
  472.     }
  473.     foreach umode [split $umodes ""] {
  474.       if {[string equal $umode i] && $sl_bfmaxbans && [llength [chanbans $chan]] >= $sl_bfmaxbans} {
  475.         putlog "sentinel: not removing +i on $chan due to full ban list."
  476.         continue
  477.       }
  478.       if {[string match *$umode* [lindex [split [getchanmode $chan]] 0]]} {
  479.          pushmode $chan -$umode
  480.          append uremoved $umode
  481.       }
  482.     }
  483.     if {[info exists uremoved]} {
  484.       putlog "sentinel: removed +$uremoved on $chan"
  485.     }
  486.   }
  487.   return 0
  488. }
  489.  
  490. proc sl_mode {nick uhost hand chan mode victim} {
  491.   global botnick sl_ban sl_bfmaxbans sl_bfnotice sl_bfull sl_flooded sl_locked sl_note sl_unlocked
  492.   set chan [string tolower $chan]
  493.   if {$mode == "+b" && $sl_bfmaxbans && !$sl_bfull($chan) && ![string match *i* [lindex [split [getchanmode $chan]] 0]] && [botisop $chan] && [llength [chanbans $chan]] >= $sl_bfmaxbans} {
  494.     putserv "MODE $chan +i"
  495.     set sl_bfull($chan) 1
  496.     utimer 5 [list set sl_bfull($chan) 0]
  497.     putlog "sentinel: locked $chan due to full ban list!"
  498.     if {$sl_bfnotice != ""} {
  499.       puthelp "NOTICE $chan :$sl_bfnotice"
  500.     }
  501.     if {[info commands sendnote] != ""} {
  502.       foreach recipient $sl_note {
  503.         if {[validuser $recipient]} {
  504.           sendnote SENTINEL $recipient "Locked $chan due to full ban list."
  505.         }
  506.       }
  507.     }
  508.   } elseif {$mode == "+i" && $sl_flooded($chan)} {
  509.     set sl_locked($chan) 1
  510.     if {$sl_ban} {
  511.       nb_killutimer "sl_*banqueue $chan"
  512.       utimer 7 [list sl_dokicks $chan] ; utimer 16 [list sl_setbans $chan]
  513.     }
  514.   } elseif {$mode == "-i" || $mode == "-m"} {
  515.     # lock modes other than +i and +m are considered auxiliary, so the channel isn't considered "unlocked" if they're removed
  516.     set sl_locked($chan) 0
  517.     set sl_unlocked($chan) [unixtime]
  518.     if {$sl_flooded($chan)} {
  519.       set sl_flooded($chan) 0
  520.       if {$mode == "-i"} {
  521.         nb_killutimer "sl_unlock $chan i"
  522.       } else {
  523.         nb_killutimer "sl_unlock $chan m"
  524.       }
  525.       nb_killutimer "sl_unlock $chan"
  526.       if {$nick != $botnick} {
  527.         putlog "sentinel: $chan unlocked by $nick"
  528.       }
  529.     }
  530.   }
  531.   return 0
  532. }
  533.  
  534. proc sl_dokicks {chan} {
  535.   global sl_avbannick sl_bobannick sl_ccbannick sl_kflooders sl_jbannick sl_pbannick
  536.   if {![botisop $chan]} {return 0}
  537.   set sl_kflooders 0
  538.   sl_kick $chan $sl_ccbannick($chan) "CTCP flooder" ; set sl_ccbannick($chan) ""
  539.   sl_kick $chan $sl_avbannick($chan) "TEXT flooder" ; set sl_avbannick($chan) ""
  540.   sl_kick $chan $sl_bobannick($chan) "BOGUS username" ; set sl_bobannick($chan) ""
  541.   set jklist $sl_jbannick($chan) ; set pklist $sl_pbannick($chan)
  542.   if {$jklist != "" && $pklist != ""} {
  543.     set klist ""
  544.     foreach nick $jklist {
  545.       if {[lsearch -exact $pklist $nick] != -1} {
  546.         lappend klist $nick
  547.       }
  548.     }
  549.     sl_kick $chan $klist "JOIN-PART flooder"
  550.   }
  551.   set sl_jbannick($chan) "" ; set sl_pbannick($chan) ""
  552.   return 0
  553. }
  554.  
  555. proc sl_kick {chan klist reason} {
  556.   global sl_kflooders sl_kicks
  557.   if {$klist != ""} {
  558.     set kicklist ""
  559.     foreach nick $klist {
  560.       if {[lsearch -exact $kicklist $nick] == -1} {
  561.         lappend kicklist $nick
  562.       }
  563.     }
  564.     unset nick
  565.     incr sl_kflooders [llength $kicklist]
  566.     foreach nick $kicklist {
  567.       if {[onchan $nick $chan] && ![onchansplit $nick $chan]} {
  568.         lappend ksend $nick
  569.         if {[llength $ksend] >= $sl_kicks} {
  570.           putserv "KICK $chan [join $ksend ,] :$reason"
  571.           unset ksend
  572.         }
  573.       }
  574.     }
  575.     if {[info exists ksend]} {
  576.       putserv "KICK $chan [join $ksend ,] :$reason"
  577.     }
  578.   }
  579.   return 0
  580. }
  581.  
  582. proc sl_setbans {chan} {
  583.   global sl_avbanhost sl_bobanhost sl_ccbanhost sl_kflooders sl_jbanhost sl_nkbanhost sl_pbanhost sl_shortlock sl_unlocked sl_wideban
  584.   if {![botonchan $chan]} {return 0}
  585.   set sl_ccbanhost($chan) [sl_dfilter $sl_ccbanhost($chan)]
  586.   set sl_avbanhost($chan) [sl_dfilter $sl_avbanhost($chan)]
  587.   set sl_nkbanhost($chan) [sl_dfilter $sl_nkbanhost($chan)]
  588.   set sl_bobanhost($chan) [sl_dfilter $sl_bobanhost($chan)]
  589.   set sl_jbanhost($chan) [sl_dfilter $sl_jbanhost($chan)]
  590.   set sl_pbanhost($chan) [sl_dfilter $sl_pbanhost($chan)]
  591.   set blist ""
  592.   if {$sl_jbanhost($chan) != "" && $sl_pbanhost($chan) != ""} {
  593.     foreach bhost $sl_jbanhost($chan) {
  594.       if {[lsearch -exact $sl_pbanhost($chan) $bhost] != -1} {
  595.         lappend blist $bhost
  596.       }
  597.     }
  598.   }
  599.   set allbans [sl_dfilter [concat $sl_ccbanhost($chan) $sl_avbanhost($chan) $sl_nkbanhost($chan) $sl_bobanhost($chan) $blist]]
  600.   if {$sl_wideban} {
  601.     sl_ban $chan [sl_dcheck $allbans] "MULTIPLE IDENT/HOST flooders"
  602.   }
  603.   sl_ban $chan $sl_ccbanhost($chan) "CTCP flooder" ; set sl_ccbanhost($chan) ""
  604.   sl_ban $chan $sl_avbanhost($chan) "TEXT flooder" ; set sl_avbanhost($chan) ""
  605.   sl_ban $chan $sl_nkbanhost($chan) "NICK flooder" ; set sl_nkbanhost($chan) ""
  606.   sl_ban $chan $sl_bobanhost($chan) "BOGUS username" ; set sl_bobanhost($chan) ""
  607.   sl_ban $chan $blist "JOIN-PART flooder"
  608.   set sl_jbanhost($chan) "" ; set sl_pbanhost($chan) ""
  609.   if {$sl_shortlock && $sl_kflooders <= 2 && [llength $allbans] <= 2 && [expr [unixtime] - $sl_unlocked($chan)] > 120} {
  610.     nb_killutimer "sl_unlock $chan*"
  611.     utimer 10 [list sl_unlock $chan]
  612.   }
  613.   return 0
  614. }
  615.  
  616. proc sl_dfilter {list} {
  617.   set newlist ""
  618.   foreach item $list {
  619.     if {[lsearch -exact $newlist $item] == -1} {
  620.       lappend newlist $item
  621.     }
  622.   }
  623.   return $newlist
  624. }
  625.  
  626. proc sl_dcheck {bhosts} {
  627.   set blist ""
  628.   foreach bhost $bhosts {
  629.     set baddr [lindex [split [maskhost $bhost] "@"] 1]
  630.     set bident [string trimleft [lindex [split $bhost "@"] 0] "~"]
  631.     if {![info exists baddrs($baddr)]} {
  632.       set baddrs($baddr) 1
  633.     } else {
  634.       incr baddrs($baddr)
  635.     }
  636.     if {![info exists bidents($bident)]} {
  637.       set bidents($bident) 1
  638.     } else {
  639.       incr bidents($bident)
  640.     }
  641.   }
  642.   foreach baddr [array names baddrs] {
  643.     if {$baddrs($baddr) >= 2} {
  644.       lappend blist *!*@$baddr
  645.     }
  646.   }
  647.   foreach bident [array names bidents] {
  648.     if {$bidents($bident) >= 2} {
  649.       lappend blist *!*$bident@*
  650.     }
  651.   }
  652.   return $blist
  653. }
  654.  
  655. proc sl_ban {chan blist reason} {
  656.   global sl_ban sl_banmax sl_globalban
  657.   if {$blist != ""} {
  658.     if {$sl_globalban} {
  659.       foreach bhost $blist {
  660.         if {![string match *!* $bhost]} {
  661.           if {[matchban *!$bhost]} {continue}
  662.           set bhost [sl_masktype $bhost]
  663.           if {[isban $bhost]} {continue}
  664.         } else {
  665.           if {[isban $bhost]} {continue}
  666.           foreach ban [banlist] {
  667.             if {[lindex $ban 5] == "sentinel" && [string match $bhost [string tolower [lindex $ban 0]]]} {
  668.               killban $ban
  669.             }
  670.           }
  671.         }
  672.         if {[llength [banlist]] >= $sl_banmax} {continue}
  673.         newban $bhost sentinel $reason $sl_ban
  674.         putlog "sentinel: banned $bhost ($reason)"
  675.         sl_ignore $bhost * $reason
  676.       }
  677.     } else {
  678.       foreach bhost $blist {
  679.         if {![string match *!* $bhost]} {
  680.           if {[matchban *!$bhost $chan]} {continue}
  681.           set bhost [sl_masktype $bhost]
  682.           if {[isban $bhost $chan]} {continue}
  683.         } else {
  684.           if {[isban $bhost $chan]} {continue}
  685.           foreach ban [banlist $chan] {
  686.             if {[lindex $ban 5] == "sentinel" && [string match $bhost [string tolower [lindex $ban 0]]]} {
  687.               killchanban $chan $ban
  688.             }
  689.           }
  690.         }
  691.         if {[llength [banlist $chan]] >= $sl_banmax} {continue}
  692.         newchanban $chan $bhost sentinel $reason $sl_ban
  693.         putlog "sentinel: banned $bhost on $chan ($reason)"
  694.         sl_ignore $bhost * $reason
  695.       }
  696.     }
  697.   }
  698.   return 0
  699. }
  700.  
  701. proc sl_ignore {ihost hand flood} {
  702.   global sl_igtime
  703.   if {$hand != "*"} {
  704.     foreach chan [channels] {
  705.       if {[matchattr $hand f|f $chan]} {return 0}
  706.     }
  707.   }
  708.   if {![string match *!* $ihost]} {
  709.     foreach ignore [ignorelist] {
  710.       if {[string match [string tolower [lindex $ignore 0]] $ihost]} {
  711.         return 0
  712.       }
  713.     }
  714.     set ihost [sl_masktype $ihost]
  715.     if {[isignore $ihost]} {return 0}
  716.   } else {
  717.     if {[isignore $ihost]} {return 0}
  718.     foreach ignore [ignorelist] {
  719.       if {[lindex $ignore 4] == "sentinel" && [string match $ihost [string tolower [lindex $ignore 0]]]} {
  720.         killignore $ignore
  721.       }
  722.     }
  723.   }
  724.   newignore $ihost sentinel $flood $sl_igtime
  725.   putlog "sentinel: added $ihost to ignore list ($flood)"
  726.   return 1
  727. }
  728.  
  729. # queuereset procs allow all queue timers to be killed easily
  730. proc sl_ccqueuereset {chan} {
  731.   global sl_ccqueue
  732.   incr sl_ccqueue($chan) -1
  733.   return 0
  734. }
  735.  
  736. proc sl_bcqueuereset {} {
  737.   global sl_bcqueue
  738.   incr sl_bcqueue -1
  739.   return 0
  740. }
  741.  
  742. proc sl_bmqueuereset {} {
  743.   global sl_bmqueue
  744.   incr sl_bmqueue -1
  745.   return 0
  746. }
  747.  
  748. proc sl_avqueuereset {chan} {
  749.   global sl_avqueue
  750.   incr sl_avqueue($chan) -1
  751.   return 0
  752. }
  753.  
  754. proc sl_txqueuereset {} {
  755.   global sl_txqueue sl_txflood
  756.   foreach chan [string tolower [channels]] {
  757.     if {[info exists sl_txqueue($chan)]} {
  758.       set sl_txqueue($chan) 0
  759.     }
  760.   }
  761.   utimer [lindex $sl_txflood 1] sl_txqueuereset
  762.   return 0
  763. }
  764.  
  765. proc sl_nkqueuereset {chan} {
  766.   global sl_nkqueue
  767.   incr sl_nkqueue($chan) -1
  768.   return 0
  769. }
  770.  
  771. proc sl_boqueuereset {chan} {
  772.   global sl_boqueue
  773.   incr sl_boqueue($chan) -1
  774.   return 0
  775. }
  776.  
  777. proc sl_jqueuereset {chan} {
  778.   global sl_jqueue
  779.   incr sl_jqueue($chan) -1
  780.   return 0
  781. }
  782.  
  783. proc sl_pqueuereset {chan} {
  784.   global sl_pqueue
  785.   incr sl_pqueue($chan) -1
  786.   return 0
  787. }
  788.  
  789. proc sl_ccbanqueue {chan} {
  790.   global sl_ccbanhost sl_ccbannick
  791.   set sl_ccbannick($chan) [lrange sl_ccbannick($chan) 1 end] ; set sl_ccbanhost($chan) [lrange sl_ccbanhost($chan) 1 end]
  792.   return 0
  793. }
  794.  
  795. proc sl_avbanqueue {chan} {
  796.   global sl_avbanhost sl_avbannick
  797.   set sl_avbannick($chan) [lrange sl_avbannick($chan) 1 end] ; set sl_avbanhost($chan) [lrange sl_avbanhost($chan) 1 end]
  798.   return 0
  799. }
  800.  
  801. proc sl_nkbanqueue {chan} {
  802.   global sl_nkbanhost
  803.   set sl_nkbanhost($chan) [lrange sl_nkbanhost($chan) 1 end]
  804.   return 0
  805. }
  806.  
  807. proc sl_bobanqueue {chan} {
  808.   global sl_bobanhost sl_bobannick
  809.   set sl_bobannick($chan) [lrange sl_bobannick($chan) 1 end] ; set sl_bobanhost($chan) [lrange sl_bobanhost($chan) 1 end]
  810.   return 0
  811. }
  812.  
  813. proc sl_jbanqueue {chan} {
  814.   global sl_jbanhost sl_jbannick
  815.   set sl_jbannick($chan) [lrange sl_jbannick($chan) 1 end] ; set sl_jbanhost($chan) [lrange sl_jbanhost($chan) 1 end]
  816.   return 0
  817. }
  818.  
  819. proc sl_pbanqueue {chan} {
  820.   global sl_pbanhost sl_pbannick
  821.   set sl_pbannick($chan) [lrange sl_pbannick($chan) 1 end] ; set sl_pbanhost($chan) [lrange sl_pbanhost($chan) 1 end]
  822.   return 0
  823. }
  824.  
  825. proc sl_flud {nick uhost hand type chan} {
  826.   global sl_flooded
  827.   set chan [string tolower $chan]
  828.   if {[validchan $chan] && $sl_flooded($chan)} {return 1}
  829.   return 0
  830. }
  831.  
  832. proc sl_lc {nick uhost hand chan arg} {
  833.   global sl_lockcmds
  834.   set chan [string tolower $chan]
  835.   if {![botisop $chan]} {return 0}
  836.   if {$sl_lockcmds == 2 && ![isop $nick $chan]} {return 0}
  837.   sl_quicklock $chan
  838.   putlog "sentinel: channel lock requested by $hand on $chan"
  839.   return 0
  840. }
  841.  
  842. proc sl_uc {nick uhost hand chan arg} {
  843.   global sl_lockcmds
  844.   set chan [string tolower $chan]
  845.   if {![botisop $chan]} {return 0}
  846.   if {$sl_lockcmds == 2 && ![isop $nick $chan]} {return 0}
  847.   putserv "MODE $chan -[sl_lockmodes]"
  848.   putlog "sentinel: channel unlock requested by $hand on $chan"
  849.   return 0
  850. }
  851.  
  852. proc sl_dcclc {hand idx arg} {
  853.   global sl_lockflags
  854.   putcmdlog "#$hand# lock $arg"
  855.   set chan [lindex [split $arg] 0]
  856.   if {$chan == "-all"} {
  857.     if {![matchattr $hand $sl_lockflags]} {
  858.       putidx $idx "You're not global +$sl_lockflags." ; return 0
  859.     }
  860.     set locklist ""
  861.     foreach chan [channels] {
  862.       if {[botisop $chan]} {
  863.         sl_quicklock $chan
  864.         lappend locklist $chan
  865.       }
  866.     }
  867.     putidx $idx "Locked [join $locklist ", "]"
  868.   } else {
  869.     if {$chan == ""} {
  870.       set chan [lindex [console $idx] 0]
  871.     }
  872.     if {![validchan $chan]} {
  873.       putidx $idx "No such channel." ; return 0
  874.     } elseif {![matchattr $hand $sl_lockflags|$sl_lockflags $chan]} {
  875.       putidx $idx "You're not +$sl_lockflags on $chan." ; return 0
  876.     } elseif {![botonchan $chan]} {
  877.       putidx $idx "I'm not on $chan" ; return 0
  878.     } elseif {![botisop $chan]} {
  879.       putidx $idx "I'm not opped on $chan" ; return 0
  880.     }
  881.     sl_quicklock $chan
  882.     putidx $idx "Locked $chan"
  883.   }
  884.   return 0
  885. }
  886.  
  887. proc sl_dccuc {hand idx arg} {
  888.   global sl_lockflags
  889.   putcmdlog "#$hand# unlock $arg"
  890.   set chan [lindex [split $arg] 0]
  891.   if {$chan == "-all"} {
  892.     if {![matchattr $hand $sl_lockflags]} {
  893.       putidx $idx "You're not global +$sl_lockflags." ; return 0
  894.     }
  895.     set locklist ""
  896.     foreach chan [channels] {
  897.       if {[botisop $chan]} {
  898.         putserv "MODE $chan -[sl_lockmodes]"
  899.         lappend locklist $chan
  900.       }
  901.     }
  902.     putidx $idx "Unlocked [join $locklist ", "]"
  903.   } else {
  904.     if {$chan == ""} {
  905.       set chan [lindex [console $idx] 0]
  906.     }
  907.     if {![validchan $chan]} {
  908.       putidx $idx "No such channel." ; return 0
  909.     } elseif {![matchattr $hand $sl_lockflags|$sl_lockflags $chan]} {
  910.       putidx $idx "You're not +$sl_lockflags on $chan." ; return 0
  911.     } elseif {![botonchan $chan]} {
  912.       putidx $idx "I'm not on $chan" ; return 0
  913.     } elseif {![botisop $chan]} {
  914.       putidx $idx "I'm not opped on $chan" ; return 0
  915.     }
  916.     putserv "MODE $chan -[sl_lockmodes]"
  917.     putidx $idx "Unlocked $chan"
  918.   }
  919.   return 0
  920. }
  921.  
  922. proc sl_quicklock {chan} {
  923.   global numversion
  924.   if {$numversion < 1050000} {
  925.     putquick "MODE $chan +[sl_lockmodes]"
  926.   } else {
  927.     putquick "MODE $chan +[sl_lockmodes]" -next
  928.   }
  929. }
  930.  
  931. proc sl_lockmodes {} {
  932.   global sl_locktimes
  933.   foreach lockmode $sl_locktimes {
  934.     append lockmodes [lindex $lockmode 0]
  935.   }
  936.   return $lockmodes
  937. }
  938.  
  939. proc sl_dcc {hand idx arg} {
  940.   global sl_avflood sl_ban sl_banmax sl_bcflood sl_boban sl_boflood sl_bmflood sl_bxsimul sl_bfmaxbans sl_ccflood sl_detectquits sl_globalban sl_igtime sl_jflood sl_kicks sl_lockcmds sl_lockflags sl_locktimes sl_nclength sl_nkflood sl_note sl_shortlock sl_tsunami sl_txflood sl_txlength
  941.   putcmdlog "#$hand# sentinel $arg"
  942.   putidx $idx "This bot is protected by sentinel.tcl by slennox"
  943.   putidx $idx "Current settings"
  944.   if {[lsearch -exact $sl_bcflood 0] != -1} {
  945.     putidx $idx "- Bot CTCP flood:           Off"
  946.   } else {
  947.     putidx $idx "- Bot CTCP flood:           [lindex $sl_bcflood 0] in [lindex $sl_bcflood 1] secs"
  948.   }
  949.   if {[lsearch -exact $sl_bmflood 0] != -1} {
  950.     putidx $idx "- Bot MSG flood:            Off"
  951.   } else {
  952.     putidx $idx "- Bot MSG flood:            [lindex $sl_bmflood 0] in [lindex $sl_bmflood 1] secs"
  953.   }
  954.   if {[lsearch -exact $sl_ccflood 0] != -1} {
  955.     putidx $idx "- Channel CTCP flood:       Off"
  956.   } else {
  957.     putidx $idx "- Channel CTCP flood:       [lindex $sl_ccflood 0] in [lindex $sl_ccflood 1] secs"
  958.   }
  959.   if {[lsearch -exact $sl_avflood 0] != -1} {
  960.     putidx $idx "- Channel TEXT flood:       Off"
  961.   } else {
  962.     putidx $idx "- Channel TEXT flood:       [lindex $sl_avflood 0] in [lindex $sl_avflood 1] secs"
  963.     if {$sl_txlength} {
  964.       putidx $idx "                            Includes PRIVMSGs over $sl_txlength chars"
  965.     } else {
  966.       putidx $idx "                            Doesn't include PRIVMSGs"
  967.     }
  968.     if {$sl_nclength == 1} {
  969.       putidx $idx "                            Includes all NOTICEs"
  970.     } elseif {$sl_nclength > 1} {
  971.       putidx $idx "                            Includes NOTICEs over $sl_nclength chars"
  972.     } else {
  973.       putidx $idx "                            Doesn't include NOTICEs"
  974.     }
  975.     if {$sl_tsunami} {
  976.       putidx $idx "                            Includes TSUNAMIs ($sl_tsunami control codes)"
  977.       putidx $idx "                            Includes AVALANCHEs"
  978.     } else {
  979.       putidx $idx "                            Doesn't include TSUNAMIs or AVALANCHEs"
  980.     }
  981.   }
  982.   if {[lsearch -exact $sl_boflood 0] != -1} {
  983.     putidx $idx "- Channel BOGUS flood:      Off"
  984.   } else {
  985.     putidx $idx "- Channel BOGUS flood:      [lindex $sl_boflood 0] in [lindex $sl_boflood 1] secs"
  986.   }
  987.   if {$sl_detectquits} {
  988.     set detectquits "quit detection ON"
  989.   } else {
  990.     set detectquits "quit detection OFF"
  991.   }
  992.   if {[lsearch -exact $sl_jflood 0] != -1} {
  993.     putidx $idx "- Channel JOIN-PART flood:  Off"
  994.   } else {
  995.     putidx $idx "- Channel JOIN-PART flood:  [lindex $sl_jflood 0] in [lindex $sl_jflood 1] secs ($detectquits)"
  996.   }
  997.   if {[lsearch -exact $sl_nkflood 0] != -1} {
  998.     putidx $idx "- Channel NICK flood:       Off"
  999.   } else {
  1000.     putidx $idx "- Channel NICK flood:       [lindex $sl_nkflood 0] in [lindex $sl_nkflood 1] secs"
  1001.   }
  1002.   if {[lsearch -exact $sl_txflood 0] != -1} {
  1003.     putidx $idx "- Channel line cap:         Off"
  1004.   } else {
  1005.     putidx $idx "- Channel line cap:         [lindex $sl_txflood 0] in [lindex $sl_txflood 1] secs"
  1006.   }
  1007.   foreach lockmode $sl_locktimes {
  1008.     lappend chanlocktimes "+[lindex $lockmode 0]: [lindex $lockmode 1] s"
  1009.   }
  1010.   putidx $idx "- Channel locktimes:        [join $chanlocktimes ", "]"
  1011.   if {$sl_shortlock && $sl_ban} {
  1012.     putidx $idx "- Small flood short lock:   Active"
  1013.   } else {
  1014.     putidx $idx "- Small flood short lock:   Inactive"
  1015.   }
  1016.   if {$sl_ban && $sl_ban < 120} {
  1017.     putidx $idx "- Channel flood bans:       $sl_ban mins"
  1018.   } elseif {$sl_ban >= 120} {
  1019.     putidx $idx "- Channel flood bans:       [expr $sl_ban / 60] hrs"
  1020.   } else {
  1021.     putidx $idx "- Channel flood bans:       Disabled"
  1022.   }
  1023.   if {!$sl_boban || [lsearch -exact $sl_boflood 0] != -1} {
  1024.     putidx $idx "- Bogus username bans:      Disabled"
  1025.   } elseif {$sl_boban > 0 && $sl_boban < 120} {
  1026.     putidx $idx "- Bogus username bans:      $sl_boban mins"
  1027.   } elseif {$sl_boban >= 120} {
  1028.     putidx $idx "- Bogus username bans:      [expr $sl_boban / 60] hrs"
  1029.   }
  1030.   if {$sl_ban || [lsearch -exact $sl_boflood 0] == -1} {
  1031.     if {$sl_globalban} {
  1032.       putidx $idx "- Ban type:                 Global [sl_masktype nick@host.domain]"
  1033.     } else {
  1034.       putidx $idx "- Ban type:                 Channel-specific [sl_masktype nick@host.domain]"
  1035.     }
  1036.   }
  1037.   if {$sl_ban || [lsearch -exact $sl_boflood 0] == -1} {
  1038.     putidx $idx "- Maximum bans:             $sl_banmax"
  1039.   }
  1040.   if {$sl_igtime > 0 && $sl_igtime < 120} {
  1041.     putidx $idx "- Flooder ignores:          $sl_igtime mins"
  1042.   } elseif {$sl_igtime >= 120} {
  1043.     putidx $idx "- Flooder ignores:          [expr $sl_igtime / 60] hrs"
  1044.   } else {
  1045.     putidx $idx "- Flooder ignores:          Permanent"
  1046.   }
  1047.   if {$sl_ban} {
  1048.     putidx $idx "- Kicks per line:           $sl_kicks"
  1049.   }
  1050.   if {!$sl_bfmaxbans} {
  1051.     putidx $idx "- Maximum channel bans:     Disabled"
  1052.   } else {
  1053.     putidx $idx "- Maximum channel bans:     $sl_bfmaxbans"
  1054.   }
  1055.   if {$sl_note != ""} {
  1056.     putidx $idx "- Flood notification:       Notifying [join $sl_note ", "]"
  1057.   } else {
  1058.     putidx $idx "- Flood notification:       Off"
  1059.   }
  1060.   if {!$sl_lockcmds} {
  1061.     putidx $idx "- Public lc/uc commands:    Disabled"
  1062.   } elseif {$sl_lockcmds == 1} {
  1063.     putidx $idx "- Public lc/uc commands:    Enabled (+$sl_lockflags users, ops not required)"
  1064.   } elseif {$sl_lockcmds == 2} {
  1065.     putidx $idx "- Public lc/uc commands:    Enabled (+$sl_lockflags users, ops required)"
  1066.   }
  1067.   if {$sl_bxsimul} {
  1068.     putidx $idx "- BitchX simulation:        On"
  1069.   } elseif {!$sl_bxsimul} {
  1070.     putidx $idx "- BitchX simulation:        Off"
  1071.   }
  1072.   return 0
  1073. }
  1074.  
  1075. if {$sl_bxsimul} {
  1076.   bind raw - 001 sl_bxserverjoin
  1077.   if {![info exists sl_bxonestack]} {
  1078.     set sl_bxonestack 0
  1079.   }
  1080.   if {![info exists sl_bxversion]} {
  1081.     set sl_bxversion [lindex {75p1+ 75p3+} [rand 2]]
  1082.   }
  1083.   set sl_bxsystem "*IX" ; set sl_bxwhoami $username ; set sl_bxmachine ""
  1084.   catch {set sl_bxsystem [exec uname -s -r]}
  1085.   catch {set sl_bxwhoami [exec id -un]}
  1086.   catch {set sl_bxmachine [exec uname -n]}
  1087.   set sl_bxjointime [unixtime]
  1088.   proc sl_bxserverjoin {from keyword arg} {
  1089.     global sl_bxjointime sl_bxisaway
  1090.     set sl_bxjointime [unixtime] ; set sl_bxisaway 0
  1091.     return 0
  1092.   }
  1093.   proc sl_bxaway {} {
  1094.     global sl_bxjointime sl_bxisaway
  1095.     if {!$sl_bxisaway} {
  1096.       puthelp "AWAY :is away: (Auto-Away after 10 mins) \[\002BX\002-MsgLog [lindex {On Off} [rand 2]]\]"
  1097.       set sl_bxisaway 1
  1098.     } else {
  1099.       puthelp "AWAY"
  1100.       set sl_bxisaway 0 ; set sl_bxjointime [unixtime]
  1101.     }
  1102.     if {![string match *sl_bxaway* [timers]]} {
  1103.       timer [expr [rand 300] + 10] sl_bxaway
  1104.     }
  1105.     return 0
  1106.   }
  1107.   if {![info exists sl_bxisaway]} {
  1108.     set sl_bxisaway 0
  1109.   }
  1110.   if {![string match *sl_bxaway* [timers]]} {
  1111.     timer [expr [rand 300] + 10] sl_bxaway
  1112.   }
  1113. }
  1114.  
  1115. proc sl_setarray {chan} {
  1116.   global sl_avbanhost sl_avbannick sl_avqueue sl_bfull sl_bobanhost sl_bobannick sl_boqueue sl_ccbanhost sl_ccbannick sl_ccqueue sl_flooded sl_jbanhost sl_jbannick sl_jqueue sl_locked sl_nkbanhost sl_nkflooding sl_nkqueue sl_pbanhost sl_pbannick sl_pqueue sl_txqueue sl_unlocked
  1117.   set chan [string tolower $chan]
  1118.   nb_killutimer "incr sl_*queue($chan) -1"
  1119.   nb_killutimer "sl_*banqueue $chan"
  1120.   nb_killutimer "sl_*queuereset $chan"
  1121.   set sl_flooded($chan) 0 ; set sl_locked($chan) 0 ; set sl_unlocked($chan) [unixtime]
  1122.   set sl_nkflooding($chan) [unixtime]
  1123.   set sl_ccqueue($chan) 0 ; set sl_ccbanhost($chan) "" ; set sl_ccbannick($chan) ""
  1124.   set sl_avqueue($chan) 0 ; set sl_avbanhost($chan) "" ; set sl_avbannick($chan) ""
  1125.   set sl_txqueue($chan) 0
  1126.   set sl_nkqueue($chan) 0 ; set sl_nkbanhost($chan) ""
  1127.   set sl_boqueue($chan) 0 ; set sl_bobanhost($chan) "" ; set sl_bobannick($chan) ""
  1128.   set sl_jqueue($chan) 0 ; set sl_jbanhost($chan) "" ; set sl_jbannick($chan) ""
  1129.   set sl_pqueue($chan) 0 ; set sl_pbanhost($chan) "" ; set sl_pbannick($chan) ""
  1130.   set sl_bfull($chan) 0
  1131.   return 0
  1132. }
  1133.  
  1134. proc sl_unsetarray {chan} {
  1135.   global sl_avbanhost sl_avbannick sl_avqueue sl_bfull sl_bobanhost sl_bobannick sl_boqueue sl_ccbanhost sl_ccbannick sl_ccqueue sl_flooded sl_jbanhost sl_jbannick sl_jqueue sl_locked sl_nkbanhost sl_nkflooding sl_nkqueue sl_pbanhost sl_pbannick sl_pqueue sl_txqueue sl_unlocked
  1136.   set chan [string tolower $chan]
  1137.   if {![validchan $chan] && [info exists sl_flooded($chan)]} {
  1138.     unset sl_flooded($chan) sl_locked($chan) sl_unlocked($chan) sl_nkflooding($chan) sl_ccqueue($chan) sl_ccbanhost($chan) sl_ccbannick($chan) sl_avqueue($chan) sl_avbanhost($chan) sl_avbannick($chan) sl_txqueue($chan) sl_nkqueue($chan) sl_nkbanhost($chan) sl_boqueue($chan) sl_bobanhost($chan) sl_bobannick($chan) sl_jqueue($chan) sl_jbanhost($chan) sl_jbannick($chan) sl_pqueue($chan) sl_pbanhost($chan) sl_pbannick($chan) sl_bfull($chan)
  1139.   }
  1140.   return 0
  1141. }
  1142.  
  1143. proc sl_settimer {} {
  1144.   foreach chan [channels] {
  1145.     sl_setarray $chan
  1146.   }
  1147.   return 0
  1148. }
  1149.  
  1150. proc sl_masktype {uhost} {
  1151.   global sl_masktype
  1152.   switch -exact -- $sl_masktype {
  1153.     0 {return *!*[string range $uhost [string first @ $uhost] end]}
  1154.     1 {return *!*$uhost}
  1155.     2 {return *!*[lindex [split [maskhost $uhost] "!"] 1]}
  1156.   }
  1157.   return
  1158. }
  1159.  
  1160. if {![info exists sl_unlocked] && ![string match *sl_settimer* [utimers]]} {
  1161.   utimer 3 sl_settimer
  1162. }
  1163.  
  1164. if {![info exists sl_bflooded]} {
  1165.   set sl_bflooded 0
  1166. }
  1167. if {![info exists sl_bcqueue]} {
  1168.   set sl_bcqueue 0
  1169. }
  1170. if {![info exists sl_bmqueue]} {
  1171.   set sl_bmqueue 0
  1172. }
  1173. if {![info exists sl_nickkick]} {
  1174.   set sl_nickkick 0
  1175. }
  1176.  
  1177. set sl_bcflood [split $sl_bcflood :] ; set sl_bmflood [split $sl_bmflood :]
  1178. # sl_txflood stays named as sl_avflood internally to simplify update
  1179. set sl_ccflood [split $sl_ccflood :] ; set sl_avflood [split $sl_txflood :]
  1180. # sl_linecap stays named as sl_txflood internally to simplify update
  1181. set sl_txflood [split $sl_linecap :] ; set sl_boflood [split $sl_boflood :]
  1182. set sl_jflood [split $sl_jflood :] ; set sl_nkflood [split $sl_nkflood :]
  1183. set sl_note [split $sl_note]
  1184.  
  1185. foreach sl_locktimepair $sl_locktimes {
  1186.   if {[lindex [split $sl_locktimepair :] 1] > 0 && [lindex [split $sl_locktimepair :] 1] < 30} {
  1187.     lappend sl_locktimeslist [list [lindex [split $sl_locktimepair :] 0] 30]
  1188.   } else {
  1189.     lappend sl_locktimeslist [split $sl_locktimepair :]
  1190.   }
  1191. }
  1192.  
  1193. set sl_locktimes $sl_locktimeslist
  1194. unset sl_locktimepair
  1195. unset sl_locktimeslist
  1196.  
  1197. if {[lsearch -glob $sl_locktimes {*i* *}] == -1} {
  1198.   lappend sl_locktimes {i 30}
  1199. }
  1200. if {[lsearch -glob $sl_locktimes {*m* *}] == -1} {
  1201.   lappend sl_locktimes {m 30}
  1202. }
  1203.  
  1204. set trigger-on-ignore 0
  1205. if {!${kick-method}} {
  1206.   set sl_kicks 8
  1207. } else {
  1208.   set sl_kicks ${kick-method}
  1209. }
  1210.  
  1211. if {$numversion <= 1040400} {
  1212.   if {$numversion >= 1032100} {
  1213.     set kick-bogus 0
  1214.   }
  1215.   if {$numversion >= 1032400} {
  1216.     set ban-bogus 0
  1217.   }
  1218. }
  1219. if {$numversion >= 1032400} {
  1220.   set kick-fun 0 ; set ban-fun 0
  1221. }
  1222. if {$numversion >= 1032500} {
  1223.   set ctcp-mode 0
  1224. }
  1225.  
  1226. if {![string match *sl_txqueuereset* [utimers]] && [lsearch -exact $sl_txflood 0] == -1} {
  1227.   utimer [lindex $sl_txflood 1] sl_txqueuereset
  1228. }
  1229.  
  1230. set nb_netcmds(rlock) "nb_sl_lock"
  1231.  
  1232. bind pub $sl_lockflags|$sl_lockflags lc sl_lc
  1233. bind pub $sl_lockflags|$sl_lockflags uc sl_uc
  1234. bind dcc $sl_lockflags|$sl_lockflags lock sl_dcclc
  1235. bind dcc $sl_lockflags|$sl_lockflags unlock sl_dccuc
  1236. if {!$sl_lockcmds} {
  1237.   unbind pub $sl_lockflags|$sl_lockflags lc sl_lc
  1238.   unbind pub $sl_lockflags|$sl_lockflags uc sl_uc
  1239.   rename sl_lc ""
  1240.   rename sl_uc ""
  1241. }
  1242. bind dcc m|m sentinel sl_dcc
  1243. bind raw - NOTICE sl_avflood
  1244. bind raw - PRIVMSG sl_avflood
  1245. if {[lsearch -exact $sl_avflood 0] != -1 && [lsearch -exact $sl_txflood 0] != -1} {
  1246.   unbind raw - NOTICE sl_avflood
  1247.   unbind raw - PRIVMSG sl_avflood
  1248.   rename sl_avflood ""
  1249. }
  1250. bind ctcp - CLIENTINFO sl_ctcp
  1251. bind ctcp - USERINFO sl_ctcp
  1252. bind ctcp - VERSION sl_ctcp
  1253. bind ctcp - FINGER sl_ctcp
  1254. bind ctcp - ERRMSG sl_ctcp
  1255. bind ctcp - ECHO sl_ctcp
  1256. bind ctcp - INVITE sl_ctcp
  1257. bind ctcp - WHOAMI sl_ctcp
  1258. bind ctcp - OP sl_ctcp
  1259. bind ctcp - OPS sl_ctcp
  1260. bind ctcp - UNBAN sl_ctcp
  1261. bind ctcp - PING sl_ctcp
  1262. bind ctcp - TIME sl_ctcp
  1263. bind msgm - * sl_bmflood
  1264. if {[lsearch -exact $sl_bmflood 0] != -1} {
  1265.   unbind msgm - * sl_bmflood
  1266.   rename sl_bmflood ""
  1267. }
  1268. bind nick - * sl_nkflood
  1269. if {[lsearch -exact $sl_nkflood 0] != -1} {
  1270.   unbind nick - * sl_nkflood
  1271.   rename sl_nkflood ""
  1272. }
  1273. bind join - * sl_jflood
  1274. bind part - * sl_pflood
  1275. bind sign - * sl_pflood
  1276. if {![info exists sl_detectquits]} {
  1277.   set sl_detectquits 0
  1278. }
  1279. if {!$sl_detectquits} {
  1280.   unbind sign - * sl_pflood
  1281. }
  1282. bind kick - * sl_pfloodk
  1283. bind flud - * sl_flud
  1284. bind mode - * sl_mode
  1285.  
  1286. return "nb_info 4.10.0"
  1287.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement