- Timestamp:
- 02/14/08 10:44:54 (11 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 modified
-
modules/interbot.tcl (modified) (15 diffs)
-
plugins/en/complex_calculator.tcl (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/interbot.tcl
r868 r885 52 52 set bMotion_interbot_timer 1 53 53 set delay [expr [rand 200] + 1700] 54 bMotion_putloglev 2 * " bMotion: starting election timer"54 bMotion_putloglev 2 * "interbot: starting election timer" 55 55 utimer $delay bMotion_interbot_next_elect 56 56 } … … 65 65 set bMotion_interbot_nextbot_score($channel) $myScore 66 66 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" 68 68 catch { 69 69 set bots [chanlist $channel] … … 71 71 #not me you idiot 72 72 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" 74 74 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" 76 76 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" 78 78 putbot $handle "bmotion elect_initial $channel $myScore" 79 79 } 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" 84 84 } 85 85 86 86 proc bMotion_interbot_catch { bot cmd args } { 87 87 global bMotionInfo 88 bMotion_putloglev 3 * " bMotion: incoming !$args!"88 bMotion_putloglev 3 * "interbot: incoming !$args!" 89 89 set args [lindex $args 0] 90 90 regexp {([^ ]+) (.+)} $args matches function params 91 91 92 bMotion_putloglev 2 * " bMotion: got command $function ($params) from $bot"92 bMotion_putloglev 2 * "interbot: got command $function ($params) from $bot" 93 93 94 94 switch -exact $function { … … 132 132 } 133 133 134 bMotion_putloglev 1 * " bMotion: Incoming election from $bot"134 bMotion_putloglev 1 * "interbot: Incoming election from $bot" 135 135 136 136 regexp "(\[#!\].+) (.+)" $params matches channel score 137 137 catch { 138 138 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" 140 140 set bMotion_interbot_nextbot_score($channel) $score 141 141 set bMotion_interbot_nextbot_nick($channel) $bot … … 151 151 } 152 152 153 bMotion_putloglev 2 * " bMotion: My score is $myScore"153 bMotion_putloglev 2 * "interbot: My score is $myScore" 154 154 155 155 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" 157 157 set bMotion_interbot_nextbot_score($channel) $myScore 158 158 set bMotion_interbot_nextbot_nick($channel) $botnick … … 174 174 global bMotion_interbot_nextbot_score bMotion_interbot_nextbot_nick 175 175 176 bMotion_putloglev 1 * " bMotion: Incoming election reply from $bot"176 bMotion_putloglev 1 * "interbot: Incoming election reply from $bot" 177 177 178 178 regexp "(\[#!\].+) (.+)" $params matches channel score 179 179 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" 181 181 set bMotion_interbot_nextbot_score($channel) $score 182 182 set bMotion_interbot_nextbot_nick($channel) $bot … … 193 193 194 194 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" 196 196 if [islinked $thisBot] { 197 197 putbot $thisBot "bmotion say $channel :$text" 198 198 return $thisBot 199 199 } 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" 201 201 return "" 202 202 } … … 207 207 global bMotionQueueTimer 208 208 209 bMotion_putloglev 4 * " bMotion: bMotionCatchSayChan $bot $params"209 bMotion_putloglev 4 * "interbot: bMotionCatchSayChan $bot $params" 210 210 211 211 if [regexp {([#!][^ ]+) :(.+)} $params matches channel txt] { … … 219 219 220 220 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" 222 222 if {$bMotionInfo(silence) == 2} { 223 223 set bMotionInfo(silence) 1 … … 251 251 #let's look to see if we know any other bots on the botnet 252 252 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" 254 254 return 1 255 255 } … … 259 259 catch { 260 260 if {$bMotion_interbot_nextbot_score($channel) < 0} { 261 bMotion_putloglev 4 * " bMotion: nextbot_score is <0, I'm not answering"262 return0261 bMotion_putloglev 4 * "interbot: nextbot_score is <0, I'm not answering" 262 set me 0 263 263 } 264 264 265 265 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" 267 267 bMotion_interbot_next_elect_do $channel 268 268 set me 1 269 269 ## /|\ 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" 274 273 #if it's noone, the winning bot will force an election anyway 275 274 return $me … … 334 333 } 335 334 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" 337 336 putbot $bot "bmotion SUP $bMotionChannels" 338 337 array unset bMotion_interbot_otherbots dummy … … 351 350 352 351 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" 354 353 array unset bMotion_interbot_otherbots dummy 355 354 } … … 374 373 set bMotion_interbot_otherbots(dummy) "" 375 374 376 putloglev d * " bMotion: Resyncing with botnet for bMotion bots"375 putloglev d * "interbot: Resyncing with botnet for bMotion bots" 377 376 putallbots "bmotion HAY $bMotionChannels ($network)" 378 377 } … … 400 399 utimer [expr [rand 900] + 300] bMotion_interbot_resync 401 400 402 bMotion_putloglev d * " bMotion: interbot module loaded"401 bMotion_putloglev d * "interbot: interbot module loaded"
