Ignore:
Timestamp:
02/01/10 18:59:10 (2 years ago)
Author:
james
Message:

add channel-level flood checking too

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/flood.tcl

    r939 r1069  
    8282 
    8383  set val 1 
    84   if [validuser $nick] { 
    85     set handle $nick 
    86   } else { 
    87     set handle [nick2hand $nick] 
    88     if {$handle == "*"} { 
    89       set handle $nick 
    90     } 
    91   } 
     84        if {[string index $nick 0] != "#"} { 
     85                if [validuser $nick] { 
     86                        set handle $nick 
     87                } else { 
     88                        set handle [nick2hand $nick] 
     89                        if {$handle == "*"} { 
     90                                set handle $nick 
     91                        } 
     92                        bMotion_putloglev d * "Using handle $handle as flood target (was $nick)" 
     93                } 
     94        } else { 
     95                bMotion_putloglev d * "Using channel $nick as flood target" 
     96                set handle $nick 
     97        } 
    9298  set lastCallback "" 
    9399  catch { 
     
    196202 
    197203proc bMotion_flood_get { nick } { 
    198   global bMotion_flood_info 
    199   if [validuser $nick] { 
    200     set handle $nick 
    201   } else { 
    202     set handle [nick2hand $nick] 
    203     if {$handle == "*"} { 
    204       set handle $nick 
    205     } 
    206   } 
    207   set flood 0 
    208   catch { 
     204        global bMotion_flood_info 
     205        if {[string index $nick 0] != "#"} { 
     206                if [validuser $nick] { 
     207                        set handle $nick 
     208                } else { 
     209                        set handle [nick2hand $nick] 
     210                        if {$handle == "*"} { 
     211                                set handle $nick 
     212                        } 
     213                } 
     214        } else { 
     215                set handle $nick 
     216        } 
     217        set flood 0 
     218        catch { 
    209219    set flood $bMotion_flood_info($handle) 
    210220  } 
     
    226236  set flood [bMotion_flood_get $nick] 
    227237  set chance 2 
    228   if {$flood > 35} { 
    229     set chance -1 
    230   } 
    231  
    232   if {$flood > 25} { 
    233     set chance -1 
    234   } 
    235  
    236   if {$flood > 15} { 
    237     set chance 1 
    238   } 
    239   set r [rand 2] 
    240   if {!($r < $chance)} { 
    241     putlog "bMotion: FLOOD check on $nick (http://www.bmotion.net:8000/bmotion/wiki/FAQDisableFlood)" 
    242     return 1 
    243   } 
     238 
     239        if {[string index $nick 0] == "#"} { 
     240                set is_chan 1 
     241        } else { 
     242                set is_chan 0 
     243        } 
     244 
     245        if {!$is_chan} { 
     246                if {$flood > 35} { 
     247                        set chance -1 
     248                } 
     249 
     250                if {$flood > 25} { 
     251                        set chance -1 
     252                } 
     253 
     254                if {$flood > 15} { 
     255                        set chance 1 
     256                } 
     257                set r [rand 2] 
     258                if {!($r < $chance)} { 
     259                        putlog "bMotion: FLOOD check on $nick (http://www.bmotion.net:8000/bmotion/wiki/FAQDisableFlood)" 
     260                        return 1 
     261                } 
     262        } else { 
     263                if {$flood > 35} { 
     264                        putlog "bMotion: FLOOD protection for $nick (http://www.bmotion.net:8000/bmotion/wiki/FAQDisableFlood)" 
     265                        return 1 
     266                } 
     267        } 
    244268  return 0 
    245269} 
Note: See TracChangeset for help on using the changeset viewer.