Changeset 885

Show
Ignore:
Timestamp:
02/14/08 10:44:54 (11 months ago)
Author:
james
Message:

add calculator plugin

Location:
trunk
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/interbot.tcl

    r868 r885  
    5252  set bMotion_interbot_timer 1 
    5353  set delay [expr [rand 200] + 1700] 
    54   bMotion_putloglev 2 * "bMotion: starting election timer" 
     54  bMotion_putloglev 2 * "interbot: starting election timer" 
    5555  utimer $delay bMotion_interbot_next_elect 
    5656} 
     
    6565  set bMotion_interbot_nextbot_score($channel) $myScore 
    6666  set bMotion_interbot_nextbot_nick($channel) $botnick 
    67   bMotion_putloglev 3 * "bMotion: assuming I'm the nextbot until I find another" 
     67  bMotion_putloglev 3 * "interbot: assuming I'm the nextbot until I find another" 
    6868  catch { 
    6969    set bots [chanlist $channel] 
     
    7171      #not me you idiot 
    7272      if [isbotnick $bot] { continue } 
    73       bMotion_putloglev 4 * "bMotion: checking $bot for election in $channel" 
     73      bMotion_putloglev 4 * "interbot: checking $bot for election in $channel" 
    7474      set handle [nick2hand $bot $channel] 
    75       bMotion_putloglev 4 * "bMotion: checking $bot's handle; $handle" 
     75      bMotion_putloglev 4 * "interbot: checking $bot's handle; $handle" 
    7676      if {[matchattr $handle b&K $channel] && [islinked $handle]} { 
    77         bMotion_putloglev 2 * "bMotion: sending elect_initial to $bot for $channel" 
     77        bMotion_putloglev 2 * "interbot: sending elect_initial to $bot for $channel" 
    7878        putbot $handle "bmotion elect_initial $channel $myScore" 
    7979      } 
    80       bMotion_putloglev 4 * "bMotion: checking $handle over"  
    81     } 
    82   } 
    83   bMotion_putloglev 3 * "bMotion: election over" 
     80      bMotion_putloglev 4 * "interbot: checking $handle over"  
     81    } 
     82  } 
     83  bMotion_putloglev 3 * "interbot: election over" 
    8484} 
    8585 
    8686proc bMotion_interbot_catch { bot cmd args } { 
    8787  global bMotionInfo 
    88   bMotion_putloglev 3 * "bMotion: incoming !$args!" 
     88  bMotion_putloglev 3 * "interbot: incoming !$args!" 
    8989  set args [lindex $args 0] 
    9090  regexp {([^ ]+) (.+)} $args matches function params 
    9191 
    92   bMotion_putloglev 2 * "bMotion: got command $function ($params) from $bot" 
     92  bMotion_putloglev 2 * "interbot: got command $function ($params) from $bot" 
    9393 
    9494  switch -exact $function { 
     
    132132        } 
    133133 
    134   bMotion_putloglev 1 * "bMotion: Incoming election from $bot" 
     134  bMotion_putloglev 1 * "interbot: Incoming election from $bot" 
    135135 
    136136        regexp "(\[#!\].+) (.+)" $params matches channel score 
    137137        catch { 
    138138                if {$score > $bMotion_interbot_nextbot_score($channel)} { 
    139                         bMotion_putloglev 2 * "bMotion: $bot now has highest score on $channel" 
     139                        bMotion_putloglev 2 * "interbot: $bot now has highest score on $channel" 
    140140                        set bMotion_interbot_nextbot_score($channel) $score 
    141141                        set bMotion_interbot_nextbot_nick($channel) $bot 
     
    151151        } 
    152152 
    153   bMotion_putloglev 2 * "bMotion: My score is $myScore" 
     153  bMotion_putloglev 2 * "interbot: My score is $myScore" 
    154154 
    155155  if {$myScore > $bMotion_interbot_nextbot_score($channel)} { 
    156     bMotion_putloglev 2 * "bMotion: Actually, I have highest score on $channel, sending out reply" 
     156    bMotion_putloglev 2 * "interbot: Actually, I have highest score on $channel, sending out reply" 
    157157    set bMotion_interbot_nextbot_score($channel) $myScore 
    158158    set bMotion_interbot_nextbot_nick($channel) $botnick 
     
    174174  global bMotion_interbot_nextbot_score bMotion_interbot_nextbot_nick  
    175175 
    176   bMotion_putloglev 1 * "bMotion: Incoming election reply from $bot" 
     176  bMotion_putloglev 1 * "interbot: Incoming election reply from $bot" 
    177177 
    178178  regexp "(\[#!\].+) (.+)" $params matches channel score 
    179179  if {$score > $bMotion_interbot_nextbot_score($channel)} { 
    180     bMotion_putloglev 2 * "bMotion: $bot now has highest score on $channel" 
     180    bMotion_putloglev 2 * "interbot: $bot now has highest score on $channel" 
    181181    set bMotion_interbot_nextbot_score($channel) $score 
    182182    set bMotion_interbot_nextbot_nick($channel) $bot 
     
    193193 
    194194  set text [bMotionInsertString $text "¬" "%"] 
    195   bMotion_putloglev 1 * "bMotion: pushing command say ($channel $text) to $thisBot" 
     195  bMotion_putloglev 1 * "interbot: pushing command say ($channel $text) to $thisBot" 
    196196  if [islinked $thisBot] { 
    197197    putbot $thisBot "bmotion say $channel :$text" 
    198198    return $thisBot 
    199199  } else { 
    200     putlog "bMotion: ALERT! Trying to talk to bot $thisBot, but it isn't linked" 
     200    putlog "interbot: ALERT! Trying to talk to bot $thisBot, but it isn't linked" 
    201201    return "" 
    202202  } 
     
    207207  global bMotionQueueTimer 
    208208 
    209   bMotion_putloglev 4 * "bMotion: bMotionCatchSayChan $bot $params" 
     209  bMotion_putloglev 4 * "interbot: bMotionCatchSayChan $bot $params" 
    210210 
    211211  if [regexp {([#!][^ ]+) :(.+)} $params matches channel txt] { 
     
    219219 
    220220    bMotionDoAction $channel $bot $txt "" 0 1 
    221     bMotion_putloglev 1 * "bMotion: done say command from $bot" 
     221    bMotion_putloglev 1 * "interbot: done say command from $bot" 
    222222    if {$bMotionInfo(silence) == 2} { 
    223223      set bMotionInfo(silence) 1 
     
    251251  #let's look to see if we know any other bots on the botnet 
    252252  if {[llength [bMotion_interbot_otherbots $channel]] == 0} { 
    253                 bMotion_putloglev 4 * "no other bots, returning 1" 
     253                bMotion_putloglev 4 * "interbot: no other bots, returning 1" 
    254254    return 1 
    255255  } 
     
    259259  catch { 
    260260    if {$bMotion_interbot_nextbot_score($channel) < 0} { 
    261       bMotion_putloglev 4 * "bMotion: nextbot_score is <0, I'm not answering" 
    262       return 0 
     261      bMotion_putloglev 4 * "interbot: nextbot_score is <0, I'm not answering" 
     262      set me 0 
    263263    } 
    264264 
    265265    if {$bMotion_interbot_nextbot_nick($channel) == $botnick} { 
    266       bMotion_putloglev 4 * "bMotion: nextbot_nick is me; calling election and returning 1" 
     266      bMotion_putloglev 4 * "interbot: nextbot_nick is me; calling election and returning 1" 
    267267      bMotion_interbot_next_elect_do $channel 
    268268      set me 1  
    269269      ## /|\ KIS hack 
    270       return 1 
    271     } 
    272   } 
    273   bMotion_putloglev 4 * "bMotion: nextbot_nick is not me"  
     270    } 
     271  } 
     272  #bMotion_putloglev 4 * "interbot: nextbot_nick is not me"  
    274273  #if it's noone, the winning bot will force an election anyway 
    275274  return $me  
     
    334333        } 
    335334  set bMotion_interbot_otherbots($bot) $channels 
    336   bMotion_putloglev d * "bMotion: Met bMotion bot $bot on channels $channels" 
     335  bMotion_putloglev d * "interbot: Met bMotion bot $bot on channels $channels" 
    337336  putbot $bot "bmotion SUP $bMotionChannels" 
    338337  array unset bMotion_interbot_otherbots dummy 
     
    351350 
    352351  set bMotion_interbot_otherbots($bot) $channels 
    353   bMotion_putloglev d * "bMotion: bMotion bot $bot on channels $channels" 
     352  bMotion_putloglev d * "interbot: bMotion bot $bot on channels $channels" 
    354353  array unset bMotion_interbot_otherbots dummy 
    355354} 
     
    374373  set bMotion_interbot_otherbots(dummy) "" 
    375374 
    376   putloglev d * "bMotion: Resyncing with botnet for bMotion bots" 
     375  putloglev d * "interbot: Resyncing with botnet for bMotion bots" 
    377376  putallbots "bmotion HAY $bMotionChannels ($network)" 
    378377} 
     
    400399utimer [expr [rand 900] + 300] bMotion_interbot_resync 
    401400 
    402 bMotion_putloglev d * "bMotion: interbot module loaded" 
     401bMotion_putloglev d * "interbot: interbot module loaded"