Changeset 954 for trunk

Show
Ignore:
Timestamp:
20/08/2008 17:55:55 (3 months ago)
Author:
james
Message:

check the queue for lines duplicating what we're seeing on the channel

Location:
trunk/modules
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/events.tcl

    r949 r954  
    2323### bMotionDoEventResponse  
    2424proc bMotionDoEventResponse { type nick host handle channel text } { 
    25         #check our global toggle 
    26   global bMotionGlobal bMotionInfo 
    27   if {$bMotionGlobal == 0} { 
    28     return 0 
    29   } 
    30  
    31   if [matchattr $handle J] { 
    32     return 0 
    33   } 
    34  
    35   set channel [string tolower $channel] 
    36  
    37   #ignore other bots 
    38   if {[matchattr $handle b] && (![matchattr $handle I])} { 
    39     set bMotionCache($channel,last) 0 
    40     return 0 
    41   } 
    42  
    43   bMotion_putloglev 4 * "entering bMotionDoEventResponse: $type $nick $host $handle $channel $text" 
    44   if { ![regexp -nocase "nick|join|quit|part|split" $type] } { 
    45     return 0 
    46   } 
    47  
    48   global bMotionInfo 
    49   set response [bMotion_plugin_find_irc_event $text $type $bMotionInfo(language)] 
    50   if {[llength $response] > 0} { 
    51     foreach callback $response { 
     25#check our global toggle 
     26        global bMotionGlobal bMotionInfo 
     27        if {$bMotionGlobal == 0} { 
     28                return 0 
     29        } 
     30 
     31        if [matchattr $handle J] { 
     32                return 0 
     33        } 
     34 
     35        set channel [string tolower $channel] 
     36 
     37        #ignore other bots 
     38        if {[matchattr $handle b] && (![matchattr $handle I])} { 
     39                set bMotionCache($channel,last) 0 
     40                return 0 
     41        } 
     42 
     43        bMotion_putloglev 4 * "entering bMotionDoEventResponse: $type $nick $host $handle $channel $text" 
     44        if { ![regexp -nocase "nick|join|quit|part|split" $type] } { 
     45                return 0 
     46        } 
     47 
     48        global bMotionInfo 
     49        set response [bMotion_plugin_find_irc_event $text $type $bMotionInfo(language)] 
     50        if {[llength $response] > 0} { 
     51                foreach callback $response { 
    5252                        bMotion_putloglev 2 * "adding flood for callback $callback" 
    5353                        bMotion_flood_add $nick $callback $text 
    54       if [bMotion_flood_check $nick] { return 0 } 
    55  
    56       bMotion_putloglev 1 * "bMotion: matched irc event plugin, running callback $callback" 
    57       set result [$callback $nick $host $handle $channel $text ] 
     54                        if [bMotion_flood_check $nick] { return 0 } 
     55 
     56                        bMotion_putloglev 1 * "bMotion: matched irc event plugin, running callback $callback" 
     57                        set result [$callback $nick $host $handle $channel $text ] 
    5858                        bMotion_putloglev 2 * "returned from callback $callback" 
    59       if {$result == 1} { 
    60         bMotion_putloglev 2 * "bMotion: $callback returned 1, breaking out..." 
    61         break 
    62       } 
    63       return 1 
    64     } 
    65     return 0 
    66   } 
    67   return 0 
     59                        if {$result == 1} { 
     60                                bMotion_putloglev 2 * "bMotion: $callback returned 1, breaking out..." 
     61                                break 
     62                        } 
     63                        return 1 
     64                } 
     65                return 0 
     66        } 
     67        return 0 
    6868} 
    6969 
    7070### bMotion_event_onjoin  
    7171proc bMotion_event_onjoin {nick host handle channel} { 
    72   #ignore me 
    73   if [isbotnick $nick] { 
    74     return 0 
    75   } 
    76  
    77   #ignore the J flag users 
    78   if [matchattr $handle J] { 
    79     return 0 
    80   } 
    81  
    82   #ignore bots without the I flag 
    83   if [matchattr $handle b-I] { 
    84     return 0 
    85   } 
    86  
    87         if {![channel get $channel bmotion]} { 
    88                 return 0 
    89         } 
    90  
    91   set result [bMotionDoEventResponse "join" $nick $host $handle $channel ""] 
     72#ignore me 
     73if [isbotnick $nick] { 
     74return 0 
     75} 
     76 
     77#ignore the J flag users 
     78if [matchattr $handle J] { 
     79return 0 
     80} 
     81 
     82#ignore bots without the I flag 
     83if [matchattr $handle b-I] { 
     84return 0 
     85} 
     86 
     87if {![channel get $channel bmotion]} { 
     88        return 0 
     89} 
     90 
     91set result [bMotionDoEventResponse "join" $nick $host $handle $channel ""] 
    9292} 
    9393 
     
    9595### bMotion_event_onpart  
    9696proc bMotion_event_onpart {nick host handle channel {msg ""}} { 
    97   #check our global toggle 
    98   global bMotionGlobal 
    99   if {$bMotionGlobal == 0} { 
    100     return 0 
    101   } 
     97#check our global toggle 
     98        global bMotionGlobal 
     99        if {$bMotionGlobal == 0} { 
     100                return 0 
     101        } 
    102102 
    103103        # channel is missing when the bot itself is parting, so ignore itself 
     
    110110        } 
    111111 
    112   bMotion_putloglev 3 * "entering bmotion_event_onpart: $nick $host $handle $channel $msg" 
     112        bMotion_putloglev 3 * "entering bmotion_event_onpart: $nick $host $handle $channel $msg" 
    113113 
    114114        bMotion_plugins_settings_set "system" "lastleft" $channel "" $nick 
    115115 
    116   #TODO: Fix this? Passing a cleaned nick around can break things 
    117   set nick [bMotion_cleanNick $nick $handle] 
    118  
    119   set result [bMotionDoEventResponse "part" $nick $host $handle $channel $msg] 
     116        #TODO: Fix this? Passing a cleaned nick around can break things 
     117        set nick [bMotion_cleanNick $nick $handle] 
     118 
     119        set result [bMotionDoEventResponse "part" $nick $host $handle $channel $msg] 
    120120} 
    121121 
    122122### bMotion_event_onquit  
    123123proc bMotion_event_onquit {nick host handle channel reason} { 
    124   global bMotionSettings bMotionInfo 
    125  
    126   #check our global toggle 
    127   global bMotionGlobal 
    128   if {$bMotionGlobal == 0} { 
    129     return 0 
    130   } 
     124        global bMotionSettings bMotionInfo 
     125 
     126        #check our global toggle 
     127        global bMotionGlobal 
     128        if {$bMotionGlobal == 0} { 
     129                return 0 
     130        } 
    131131 
    132132        # channel is missing when the bot itself is quiting, so ignore itself 
     
    139139        } 
    140140 
    141   set nick [bMotion_cleanNick $nick $handle] 
    142  
    143   bMotion_plugins_settings_set "system" "lastleft" $channel "" $nick 
    144  
    145   if {$bMotionInfo(brig) != ""} { 
    146     #check if that person was in the brig 
    147     regexp -nocase "(.+)@(.+)" $bMotionInfo(brig) pop brigNick brigChannel 
    148     if [string match -nocase $nick $brigNick] { 
    149       set bMotionInfo(brig) "" 
    150       bMotionDoAction $brigChannel "" "Curses! They escaped from the brig." 
    151       return 0 
    152     } 
    153   } 
    154   set result [bMotionDoEventResponse "quit" $nick $host $handle $channel $reason ] 
     141        set nick [bMotion_cleanNick $nick $handle] 
     142 
     143        bMotion_plugins_settings_set "system" "lastleft" $channel "" $nick 
     144 
     145        if {$bMotionInfo(brig) != ""} { 
     146        #check if that person was in the brig 
     147                regexp -nocase "(.+)@(.+)" $bMotionInfo(brig) pop brigNick brigChannel 
     148                if [string match -nocase $nick $brigNick] { 
     149                        set bMotionInfo(brig) "" 
     150                        bMotionDoAction $brigChannel "" "Curses! They escaped from the brig." 
     151                        return 0 
     152                } 
     153        } 
     154        set result [bMotionDoEventResponse "quit" $nick $host $handle $channel $reason ] 
    155155} 
    156156 
    157157### bMotion_event_main  
    158158proc bMotion_event_main {nick host handle channel text} { 
    159   #check our global toggle 
    160   global bMotionGlobal bMotionPluginHistory 
    161   if {$bMotionGlobal == 0} { 
    162     return 0 
    163   } 
    164  
    165   ## Global definitions ## 
    166   global mood botnick 
    167   global bMotionLastEvent bMotionSettings botnicks bMotionCache bMotionInfo 
    168   global bMotionThisText bMotionOriginalInput bMotionOriginalNick 
    169  
    170   if [matchattr $handle J] { 
    171     return 0 
    172   } 
    173  
    174   set bMotionOriginalNick $nick 
    175  
    176   set channel [string tolower $channel] 
    177  
    178   #ignore other bots  
    179   if {[matchattr $handle b] && (![matchattr $handle I])} { 
    180     set bMotionCache($channel,last) 0 
    181     return 0 
    182   } 
     159#check our global toggle 
     160        global bMotionGlobal bMotionPluginHistory 
     161        if {$bMotionGlobal == 0} { 
     162                return 0 
     163        } 
     164 
     165        ## Global definitions ## 
     166        global mood botnick 
     167        global bMotionLastEvent bMotionSettings botnicks bMotionCache bMotionInfo 
     168        global bMotionThisText bMotionOriginalInput bMotionOriginalNick 
     169 
     170        if [matchattr $handle J] { 
     171                return 0 
     172        } 
     173 
     174        set bMotionOriginalNick $nick 
     175 
     176        set channel [string tolower $channel] 
     177 
     178        #ignore other bots  
     179        if {[matchattr $handle b] && (![matchattr $handle I])} { 
     180                set bMotionCache($channel,last) 0 
     181                return 0 
     182        } 
    183183 
    184184        #make sure we're allowed to talk in here  
    185   if {![channel get $channel bmotion]} { 
    186     return 0 
    187   } 
     185        if {![channel get $channel bmotion]} { 
     186                return 0 
     187        } 
    188188 
    189189        #don't trigger on !seen etc  
     
    196196                return 0 
    197197        } 
    198          
    199   bMotion_putloglev 4 * "bMotion: entering bMotion_event_main with nick: $nick host: $host handle: $handle chan: $channel text: $text" 
    200  
    201   set bMotionOriginalInput $text 
    202  
    203   #filter bold, etc codes out  
    204   regsub -all "\002" $text "" text 
    205   regsub -all "\022" $text "" text 
    206   regsub -all "\037" $text "" text 
     198 
     199        bMotion_putloglev 4 * "bMotion: entering bMotion_event_main with nick: $nick host: $host handle: $handle chan: $channel text: $text" 
     200 
     201        bMotion_queue_dupecheck $text $channel 
     202 
     203        set bMotionOriginalInput $text 
     204 
     205        #filter bold, etc codes out  
     206        regsub -all "\002" $text "" text 
     207        regsub -all "\022" $text "" text 
     208        regsub -all "\037" $text "" text 
    207209 
    208210        # thanks, anonymous ticket poster (ticket #125) 
    209   regsub -all "\003\[0-9\]{0,2}(,\[0-9\]{1,2})?" $text "" text 
    210    
    211   #try stripcodes (eggdrop 1.6.17+) 
    212   catch { 
    213         set text [stripcodes bcruag $text] 
    214   } 
     211        regsub -all "\003\[0-9\]{0,2}(,\[0-9\]{1,2})?" $text "" text 
     212 
     213        #try stripcodes (eggdrop 1.6.17+) 
     214        catch { 
     215                set text [stripcodes bcruag $text] 
     216        } 
    215217 
    216218        bMotion_check_botnicks 
    217219 
    218   #does this look like a paste?  
    219   if [regexp -nocase {^[([]?[0-9]{2}[-:.][0-9]{2}. ?[[<(]?[%@+]?[a-z0-9` ]+[@+%]?. \w+} $text] { 
    220     return 0 
    221   } 
    222  
    223   ## Update the channel idle tracker  
    224   set bMotionLastEvent($channel) [clock seconds] 
    225  
    226   #don't let people break us  
    227   if {![matchattr $handle n]} { 
    228     if [regexp -nocase "%(pronoun|me|noun|colen|percent|VAR|\\|)" $text] { 
    229       regsub -all "%" $text "%percent" text 
    230     } 
    231   } 
    232   regsub -all "\</" $text "%slash" text 
    233          
    234   #If this isn't just a smiley of some kind, trim smilies  
    235   if {[string length $text] >= ([string length $botnick] + 4)} { 
    236     regsub -all -nocase {[;:=]-?[()d<>/sp9x]} $text "" text 
    237     regsub -all {([\-^])_*[\-^];*} $text "" text 
     220        #does this look like a paste?  
     221        if [regexp -nocase {^[([]?[0-9]{2}[-:.][0-9]{2}. ?[[<(]?[%@+]?[a-z0-9` ]+[@+%]?. \w+} $text] { 
     222                return 0 
     223        } 
     224 
     225        ## Update the channel idle tracker  
     226        set bMotionLastEvent($channel) [clock seconds] 
     227 
     228        #don't let people break us  
     229        if {![matchattr $handle n]} { 
     230                if [regexp -nocase "%(pronoun|me|noun|colen|percent|VAR|\\|)" $text] { 
     231                        regsub -all "%" $text "%percent" text 
     232                } 
     233        } 
     234        regsub -all "\</" $text "%slash" text 
     235 
     236        #If this isn't just a smiley of some kind, trim smilies  
     237        if {[string length $text] >= ([string length $botnick] + 4)} { 
     238                regsub -all -nocase {[;:=]-?[()d<>/sp9x]} $text "" text 
     239                regsub -all {([\-^])_*[\-^];*} $text "" text 
    238240                regsub -all {\\o/} $text "" text 
    239   } 
    240  
    241   #Trim stuff  
    242   set text [string trim $text] 
    243  
    244   ## Dump double+ spaces  
    245   regsub -all "  +" $text " " text 
    246  
    247   ## Update the last-talked flag for the join system 
    248   bMotion_plugins_settings_set "system:join" "lasttalk" $channel "" 0 
    249  
    250   set bMotionThisText $text 
    251  
    252   #if we spoke last, add "$botnick: " if it's not in the line  
    253   if {![regexp -nocase $botnicks $text] && ([bMotion_did_i_speak_last $channel] || ([bMotion_setting_get "bitlbee"] == "1"))} { 
    254         if [regexp {^[^:]+:.+} $text] { 
    255                         #since our nick isn't in the line and they're addressing someone, drop this line 
    256                         return 0 
    257                 } 
    258     set text "${botnick}: $text" 
    259   } 
    260   
    261   if {[bMotion_setting_get "bitlbee"] == "1"} { 
    262     bMotion_putloglev d * "bitlbee incoming from $nick: $text" 
    263   } 
    264  
    265   #check for someone breaking the loop of lastSpoke  
    266   if {[regexp -nocase "(i'm not talking to|not) you" $text] && $bMotionCache($channel,last)} { 
    267     bMotionDoAction $channel $nick "oh" 
    268     set bMotionCache($channel,last) 0 
    269     return 0 
    270   } 
    271   set bMotionCache($channel,last) 0 
    272  
    273   #Run the simple plugins  
    274   set response [bMotion_plugin_find_simple $text $bMotionInfo(language)] 
    275   if {$response != ""} { 
    276     bMotion_flood_add $nick "" $text 
    277     if [bMotion_flood_check $nick] { return 0 } 
    278     set nick [bMotionGetRealName $nick $host] 
    279     bMotionDoAction $channel $nick [pickRandom $response] 
    280     return 0 
    281   } 
    282  
    283   #Run the complex plugins  
    284   set response [bMotion_plugin_find_complex $text $bMotionInfo(language)] 
    285   if {[llength $response] > 0} { 
    286     #set nick [bMotionGetRealName $nick $host] 
    287     bMotion_putloglev 1 * "going to run plugins: $response" 
    288     foreach callback $response { 
     241        } 
     242 
     243        #Trim stuff  
     244        set text [string trim $text] 
     245 
     246        ## Dump double+ spaces  
     247        regsub -all "  +" $text " " text 
     248 
     249        ## Update the last-talked flag for the join system 
     250        bMotion_plugins_settings_set "system:join" "lasttalk" $channel "" 0 
     251 
     252        set bMotionThisText $text 
     253 
     254        #if we spoke last, add "$botnick: " if it's not in the line  
     255        if {![regexp -nocase $botnicks $text] && ([bMotion_did_i_speak_last $channel] || ([bMotion_setting_get "bitlbee"] == "1"))} { 
     256                if [regexp {^[^:]+:.+} $text] { 
     257                #since our nick isn't in the line and they're addressing someone, drop this line 
     258                        return 0 
     259                } 
     260                set text "${botnick}: $text" 
     261        } 
     262 
     263        if {[bMotion_setting_get "bitlbee"] == "1"} { 
     264                bMotion_putloglev d * "bitlbee incoming from $nick: $text" 
     265        } 
     266 
     267        #check for someone breaking the loop of lastSpoke  
     268        if {[regexp -nocase "(i'm not talking to|not) you" $text] && $bMotionCache($channel,last)} { 
     269                bMotionDoAction $channel $nick "oh" 
     270                set bMotionCache($channel,last) 0 
     271                return 0 
     272        } 
     273        set bMotionCache($channel,last) 0 
     274 
     275        #Run the simple plugins  
     276        set response [bMotion_plugin_find_simple $text $bMotionInfo(language)] 
     277        if {$response != ""} { 
     278                bMotion_flood_add $nick "" $text 
     279                if [bMotion_flood_check $nick] { return 0 } 
     280                set nick [bMotionGetRealName $nick $host] 
     281                bMotionDoAction $channel $nick [pickRandom $response] 
     282                return 0 
     283        } 
     284 
     285        #Run the complex plugins  
     286        set response [bMotion_plugin_find_complex $text $bMotionInfo(language)] 
     287        if {[llength $response] > 0} { 
     288        #set nick [bMotionGetRealName $nick $host] 
     289                bMotion_putloglev 1 * "going to run plugins: $response" 
     290                foreach callback $response { 
    289291                        bMotion_putloglev 1 * "bMotion: doing flood for $callback..." 
    290       if [bMotion_flood_check $nick] { return 0 } 
    291  
    292       bMotion_putloglev 1 * "bMotion: `- running callback $callback" 
     292                        if [bMotion_flood_check $nick] { return 0 } 
     293 
     294                        bMotion_putloglev 1 * "bMotion: `- running callback $callback" 
    293295                        set result 0 
    294296                        set result [$callback $nick $host $handle $channel $text] 
     
    300302                        # they should return 0 if they don't trigger 
    301303 
    302       if {$result > 0} { 
     304                        if {$result > 0} { 
    303305                                if {$result == 1} { 
    304306                                        bMotion_flood_add $nick $callback $text 
    305307                                } 
    306         bMotion_putloglev 2 * "bMotion:    `-$callback returned $result, breaking out..." 
    307         break 
    308       } 
    309     } 
    310   } 
    311  
    312   #Check for all caps  
    313   regsub -all {[^A-Za-z]} $text "" textChars 
    314   regsub -all {[a-z]} $textChars "" textLowerChars 
    315   if {(([string length $textChars] > 4) && ([expr [string length $textLowerChars] / [string length $textChars]] > 0.9)) || 
    316         [regexp ".+!{4,}" $text]} { 
    317     global blownAways 
    318     if {[rand 60] >= 55} { 
    319       bMotionDoAction $channel $nick "%VAR{blownAways}" 
    320       return 0 
    321     } 
    322   } 
    323  
    324   #Reload config files  
     308                                bMotion_putloglev 2 * "bMotion:          `-$callback returned $result, breaking out..." 
     309                                break 
     310                        } 
     311                } 
     312        } 
     313 
     314        #Check for all caps  
     315        regsub -all {[^A-Za-z]} $text "" textChars 
     316        regsub -all {[a-z]} $textChars "" textLowerChars 
     317        if {(([string length $textChars] > 4) && ([expr [string length $textLowerChars] / [string length $textChars]] > 0.9)) || 
     318                [regexp ".+!{4,}" $text]} { 
     319                global blownAways 
     320                if {[rand 60] >= 55} { 
     321                        bMotionDoAction $channel $nick "%VAR{blownAways}" 
     322                        return 0 
     323                } 
     324        } 
     325 
     326        #Reload config files  
    325327        #TODO: move this into a plugin? 
    326   if [regexp -nocase "${botnicks},?:? re(hash|load)( your config files?)?" $text] { 
    327     #putlog "bMotion: $nick asked me to rehash in $channel" 
    328     global bMotion_testing bMotionRoot 
    329  
    330     if [matchattr $handle m] { 
    331       #check we're not going to die 
    332       catch { 
    333         bMotion_putloglev d * "bMotion: Testing new code..." 
    334         set bMotion_testing 1 
    335         source "$bMotionRoot/bMotion.tcl" 
    336       } msg 
    337  
    338       if {$msg != ""} { 
    339         putlog "bMotion: FATAL: Cannot rehash due to error: $msg" 
    340         putserv "NOTICE $nick :FATAL: Cannot rehash: $msg" 
    341         putchan $channel "A tremendous error occurred!" 
    342         return 0 
    343       } else { 
    344         bMotion_putloglev d * "bMotion: New code ok, rehashing..." 
    345                                 bMotion_plugins_settings_set "system" "rehash" "" "" $channel 
    346         set bMotion_testing 0 
    347         if {[matchattr $handle m]} { 
    348           putchan $channel [bMotionDoInterpolation "%VAR{rehashes}" "" ""] 
    349           rehash 
    350           return 0 
    351         } 
    352       } 
    353     } else { 
    354                         #don't respond here because there's no flood protection 
    355       return 0 
    356     } 
    357   } 
     328        if [regexp -nocase "${botnicks},?:? re(hash|load)( your config files?)?" $text] { 
     329        #putlog "bMotion: $nick asked me to rehash in $channel" 
     330                global bMotion_testing bMotionRoot 
     331 
     332                if [matchattr $handle m] { 
     333                #check we're not going to die 
     334                catch { 
     335                bMotion_putloglev d * "bMotion: Testing new code..." 
     336                set bMotion_testing 1 
     337                source "$bMotionRoot/bMotion.tcl" 
     338                } msg 
     339 
     340                if {$msg != ""} { 
     341                        putlog "bMotion: FATAL: Cannot rehash due to error: $msg" 
     342                        putserv "NOTICE $nick :FATAL: Cannot rehash: $msg" 
     343                        putchan $channel "A tremendous error occurred!" 
     344                        return 0 
     345                } else { 
     346                        bMotion_putloglev d * "bMotion: New code ok, rehashing..." 
     347                        bMotion_plugins_settings_set "system" "rehash" "" "" $channel 
     348                        set bMotion_testing 0 
     349                        if {[matchattr $handle m]} { 
     350                                putchan $channel [bMotionDoInterpolation "%VAR{rehashes}" "" ""] 
     351                                rehash 
     352                                return 0 
     353                        } 
     354                } 
     355                } else { 
     356                #don't respond here because there's no flood protection 
     357                        return 0 
     358                } 
     359        } 
    358360 
    359361        #tell the names we have  
    360362        #TODO: move this into a plugin? 
    361363        if [regexp -nocase "${botnicks}:?,? say my names?(,? bitch)?" $text] { 
    362                 if {($handle == "*") || ($handle == "")}  { 
    363                         #no handle = no saving IRL 
     364                if {($handle == "*") || ($handle == "")}        { 
     365                #no handle = no saving IRL 
    364366                        set lastnick [bMotion_plugins_settings_get "events" "last_irl_fail" $channel ""] 
    365367                        if {$lastnick == $nick} { 
     
    382384        } 
    383385 
    384   #shut up  
     386        #shut up  
    385387        #TODO: move this into a plugin? 
    386   if [regexp -nocase "^${botnicks}:?,? (silence|shut up|be quiet|go away)" $text] { 
    387     driftFriendship $nick -10 
    388     bMotionSilence $nick $host $channel 
    389     return 0 
    390   } 
    391  
    392   if [regexp -nocase "(silence|shut up|be quiet|go away),?;? ${botnicks}" $text] { 
    393     driftFriendship $nick -10 
    394     bMotionSilence $nick $host $channel 
    395     return 0 
    396   } 
     388        if [regexp -nocase "^${botnicks}:?,? (silence|shut up|be quiet|go away)" $text] { 
     389                driftFriendship $nick -10 
     390                bMotionSilence $nick $host $channel 
     391                return 0 
     392        } 
     393 
     394        if [regexp -nocase "(silence|shut up|be quiet|go away),?;? ${botnicks}" $text] { 
     395                driftFriendship $nick -10 
     396                bMotionSilence $nick $host $channel 
     397                return 0 
     398        } 
    397399 
    398400        #catch actions in stars  
    399   #This is the clever bit. If the text is "*blah blah blah*" reinject it into bMotion as an action ## 
    400   if [regexp {^\*(.+)\*$} $text blah action] { 
    401     bMotion_putloglev 1 * "Unhandled *$action* by $nick in $channel... redirecting to action handler" 
    402     bMotion_event_action $nick $host $handle $channel "" $action 
    403     return 0 
    404   } 
     401        #This is the clever bit. If the text is "*blah blah blah*" reinject it into bMotion as an action ## 
     402        if [regexp {^\*(.+)\*$} $text blah action] { 
     403                bMotion_putloglev 1 * "Unhandled *$action* by $nick in $channel... redirecting to action handler" 
     404                bMotion_event_action $nick $host $handle $channel "" $action 
     405                return 0 
     406        } 
    405407} 
    406408 
     
    408410proc bMotion_event_action {nick host handle dest keyword text} { 
    409411 
    410   #check our global toggle 
    411   global bMotionGlobal 
    412   if {$bMotionGlobal == 0} { 
    413     return 0 
    414   } 
    415  
    416   global botnick mood rarrs smiles unsmiles botnicks bMotionCache bMotionSettings bMotionInfo 
    417   set dest [channame2dname $dest] 
    418   set channel $dest 
    419  
    420   if [matchattr $handle J] { 
    421     return 0 
    422   } 
    423  
    424   #ignore other bots 
    425   if {[matchattr $handle b]} { 
    426     return 0 
    427   } 
     412#check our global toggle 
     413        global bMotionGlobal 
     414        if {$bMotionGlobal == 0} { 
     415                return 0 
     416        } 
     417 
     418        global botnick mood rarrs smiles unsmiles botnicks bMotionCache bMotionSettings bMotionInfo 
     419        set dest [channame2dname $dest] 
     420        set channel $dest 
     421 
     422        if [matchattr $handle J] { 
     423                return 0 
     424        } 
     425 
     426        #ignore other bots 
     427        if {[matchattr $handle b]} { 
     428                return 0 
     429        } 
    428430 
    429431        if {![channel get $channel bmotion]} {