Changeset 1069


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

add channel-level flood checking too

Location:
trunk/modules
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/events.tcl

    r961 r1069  
    266266 
    267267        #check for someone breaking the loop of lastSpoke  
    268         if {[regexp -nocase "(i'm not talking to|not) you" $text] && $bMotionCache($channel,last)} { 
     268        if {[regexp -nocase "(i'm not talking to|not) you" $text] && [bMotion_did_i_speak_last $channel]} { 
    269269                bMotionDoAction $channel $nick "oh" 
    270270                set bMotionCache($channel,last) 0 
     
    278278                bMotion_flood_add $nick "" $text 
    279279                if [bMotion_flood_check $nick] { return 0 } 
     280                if [bMotion_flood_check $channel] { return 0 } 
     281                bMotion_flood_add $channel "" $text 
    280282                set nick [bMotionGetRealName $nick $host] 
    281283                bMotionDoAction $channel $nick [pickRandom $response] 
     
    287289        if {[llength $response] > 0} { 
    288290        #set nick [bMotionGetRealName $nick $host] 
     291                if [bMotion_flood_check $channel] { return 0 } 
    289292                bMotion_putloglev 1 * "going to run plugins: $response" 
    290293                foreach callback $response { 
     
    295298                        set result 0 
    296299                        set result [$callback $nick $host $handle $channel $text] 
     300                        bMotion_putloglev d * "returned from $callback" 
    297301                        set bMotionCache(lastPlugin) $callback 
    298302                        bMotion_plugin_history_add $channel "complex" $callback 
     
    304308                        if {$result > 0} { 
    305309                                if {$result == 1} { 
     310                                        bMotion_putloglev 1 * "adding flood counters" 
    306311                                        bMotion_flood_add $nick $callback $text 
     312                                        bMotion_flood_add $channel $callback $text 
    307313                                } 
    308314                                bMotion_putloglev 2 * "bMotion:          `-$callback returned $result, breaking out..." 
     
    453459        if {$response != ""} { 
    454460                bMotion_flood_add $nick "" $text 
     461                if [bMotion_flood_check $nick] { return 0 } 
     462                if [bMotion_flood_check $channel] { return - } 
     463                bMotion_flood_add $channel "" $text 
    455464                bMotion_putloglev 1 * "bMotion: matched simple action plugin, outputting $response..." 
    456465                set nick [bMotionGetRealName $nick $host] 
     
    463472        if {[llength $response] > 0} { 
    464473        #set nick [bMotionGetRealName $nick $host] 
     474                if [bMotion_flood_check $channel] { return 0 } 
    465475                bMotion_putloglev 1 * "going to run action plugins: $response" 
    466476                foreach callback $response { 
     
    473483                                if {$result == 1} { 
    474484                                        bMotion_flood_add $nick $callback $text 
     485                                        bMotion_flood_add $channel $callback $text 
    475486                                } 
    476487                                bMotion_putloglev 2 * "bMotion:          `-$callback returned $result, breaking out..." 
  • 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.