Changeset 868

Show
Ignore:
Timestamp:
11/03/07 19:31:06 (14 months ago)
Author:
james
Message:

add option to disable/enable interbot stuff
update interbot manangement plugin for enable/disable
write help for interbot plugin
add default interbot enable setting to settings

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/interbot.tcl

    r832 r868  
    2222# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
    2323############################################################################### 
     24 
     25# allow people to turn off the interbot stuff if they don't want it 
     26# these values should be set in the settings file, but we'll define 
     27# some defaults here 
     28 
     29if {![info exists bMotion_interbot_enable]} { 
     30        set bMotion_interbot_enable 1 
     31} 
    2432 
    2533# Elect a new bot to speak for each channel 
     
    3139 
    3240  global bMotionInfo bMotion_interbot_timer bMotionChannels 
     41        global bMotion_interbot_enable 
     42 
     43        if {!$bMotion_interbot_enable} { 
     44                return 
     45        } 
     46 
    3347  catch { 
    3448    foreach chan $bMotionChannels { 
     
    112126  #another bot is forcing an election 
    113127  global bMotion_interbot_nextbot_score bMotion_interbot_nextbot_nick botnick bMotionInfo 
    114         global BMOTION_SLEEP bMotionSettings 
     128        global BMOTION_SLEEP bMotionSettings bMotion_interbot_enable 
     129 
     130        if {![info exists bMotion_interbot_enable]} { 
     131                return 
     132        } 
     133 
    115134  bMotion_putloglev 1 * "bMotion: Incoming election from $bot" 
    116135 
     
    167186proc bMotionSendSayChan { channel text thisBot} { 
    168187  #replace all ¬ with % 
     188        global bMotion_interbot_enable 
     189 
     190        if {!$bMotion_interbot_enable} { 
     191                return "" 
     192        } 
     193 
    169194  set text [bMotionInsertString $text "¬" "%"] 
    170195  bMotion_putloglev 1 * "bMotion: pushing command say ($channel $text) to $thisBot" 
     
    208233proc bMotion_interbot_me_next { channel } { 
    209234  global bMotion_interbot_nextbot_nick bMotion_interbot_nextbot_score botnick 
     235        global bMotion_interbot_enable 
    210236 
    211237  set channel [string tolower $channel] 
     238 
     239        if {!$bMotion_interbot_enable} { 
     240                # if interbot stuff is turned off, we'll have to assume we should respond 
     241                # else we'd never say anything... 
     242                return 1 
     243        } 
    212244 
    213245        bMotion_putloglev 2 * "checking interbot_me_next for $channel" 
     
    287319proc bMotion_interbot_hay { bot channels } { 
    288320  #we've met another bmotion bot, we need to tell it what channels we're on 
    289   global bMotion_interbot_otherbots network bMotionChannels 
     321  global bMotion_interbot_otherbots network bMotionChannels bMotion_interbot_enable 
     322 
     323        if {!$bMotion_interbot_enable} { 
     324                return 
     325        } 
     326 
    290327        bMotion_update_chanlist 
    291328        if [regexp -nocase {(.+) network:(.+)} $channels matches chans nw] { 
     
    307344proc bMotion_interbot_sup { bot channels } { 
    308345  #we've met another bmotion bot 
    309   global bMotion_interbot_otherbots 
     346  global bMotion_interbot_otherbots bMotion_interbot_enable 
     347 
     348        if {!$bMotion_interbot_enable} { 
     349                return 
     350        } 
     351 
    310352  set bMotion_interbot_otherbots($bot) $channels 
    311353  bMotion_putloglev d * "bMotion: bMotion bot $bot on channels $channels" 
     
    320362proc bMotion_interbot_resync { } { 
    321363  #let's find out who's on the botnet 
    322   global bMotion_interbot_otherbots network bMotionChannels 
     364  global bMotion_interbot_otherbots network bMotionChannels bMotion_interbot_enable 
     365 
     366  utimer [expr [rand 900] + 300] bMotion_interbot_resync 
     367 
     368        if {$bMotion_interbot_enable != 1} { 
     369                return 
     370        } 
     371 
    323372        bMotion_update_chanlist 
    324373  unset bMotion_interbot_otherbots 
     
    327376  putloglev d * "bMotion: Resyncing with botnet for bMotion bots" 
    328377  putallbots "bmotion HAY $bMotionChannels ($network)" 
    329   utimer [expr [rand 900] + 300] bMotion_interbot_resync 
    330378} 
    331379 
  • trunk/modules/settings.sample.tcl

    r834 r868  
    142142set bMotionSettings(typingSpeed) 0.05 
    143143 
     144# use the interbot stuff? 
     145# by default, bMotion will broadcast on the botnet to find other bMotions 
     146# so that it can talk to them (when they're in the same channel) 
     147set bMotion_interbot_enable 1 
    144148 
    145149 
  • trunk/plugins/admin_general.tcl

    r847 r868  
    2222bMotion_plugin_add_management "settings" "^settings" n bMotion_plugin_management_settings "any" 
    2323bMotion_plugin_add_management "global" "^global" n bMotion_plugin_management_global "any" 
    24 bMotion_plugin_add_management "interbot" "^interbot" n bMotion_plugin_management_interbot "any" 
     24bMotion_plugin_add_management "interbot" "^interbot" n bMotion_plugin_management_interbot "any" bMotion_plugin_management_interbot_help 
    2525bMotion_plugin_add_management "flux" "^flux capacitors?" n bMotion_plugin_management_flux "any" 
    2626 
     
    244244                bMotion_putadmin [bMotion_interbot_otherbots $chan] 
    245245        } 
     246 
     247        if [regexp -nocase "enable" $text] { 
     248                global bMotion_interbot_enable 
     249 
     250                if {$bMotion_interbot_enable} { 
     251                        bMotion_putadmin "Interbot stuff is already enabled." 
     252                        return 
     253                } else { 
     254                        set bMotion_interbot_enable 1 
     255                        bMotion_putadmin "Interbot stuff enabled." 
     256                        return 
     257                } 
     258        } 
     259 
     260        if [regexp -nocase "disable" $text] { 
     261                global bMotion_interbot_enable 
     262 
     263                if {!$bMotion_interbot_enable} { 
     264                        bMotion_putadmin "Interbot stuff is already disabled." 
     265                        return 
     266                } else { 
     267                        set bMotion_interbot_enable 0 
     268                        bMotion_putadmin "Interbot stuff disabled." 
     269                        return 
     270                } 
     271        } 
     272} 
     273 
     274proc bMotion_plugin_management_interbot_help { } { 
     275        bMotion_putadmin "Manage the interbot communication stuff." 
     276        bMotion_putadmin "  .bmotion interbot next #channel" 
     277        bMotion_putadmin "    Report the next bot for #channel" 
     278        bMotion_putadmin "  .bmotion interbot elect #channel" 
     279        bMotion_putadmin "    Force an election for #channel" 
     280        bMotion_putadmin "  .bmotion interbot bots #channel" 
     281        bMotion_putadmin "    Report bots discovered in #channel" 
     282        bMotion_putadmin "  .bmotion interbot enable" 
     283        bMotion_putadmin "  .bmotion interbot disable" 
     284        bMotion_putadmin "    Enable/disable interbot stuff entirely" 
    246285} 
    247286