Changeset 1004


Ignore:
Timestamp:
04/28/09 19:23:31 (3 years ago)
Author:
james
Message:

Add new away admin plugin
Add some debug to randomstuff/away code
Include away status in .bmotion status
Fix .bmotion help being broken

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/plugins.tcl

    r961 r1004  
    188188        foreach key [array names bMotion_plugins_management] { 
    189189                if [string match -nocase $name $key] { 
     190                        set blah $bMotion_plugins_management($key) 
    190191                        set helpcallback [lindex $blah $BMOTION_PLUGIN_MANAGEMENT_HELPCALLBACK] 
    191192                        return $helpcallback 
  • trunk/modules/system.tcl

    r1003 r1004  
    166166        global bMotionChannels bMotionInfo 
    167167 
     168        bMotion_putloglev 4 * "bMotion_random_away" 
     169 
    168170        set timeNow [clock seconds] 
    169171 
     
    171173        if {[bMotion_setting_get "bitlbee"]} { 
    172174                #never go away in bitlbee 
     175                bMotion_putloglev "going away is disabled in bitlbee mode" 
    173176                return 0 
    174177        } 
     
    176179        #override if we should never go away 
    177180        if {[bMotion_setting_get "useAway"] != 1} { 
     181                bMotion_putloglev "going away is disabled" 
    178182                return 0 
    179183        } 
     
    196200 
    197201        if {($timeNow - $mostRecent) < $gapTime} { 
     202                bMotion_putloglev 1 * "most recent is busy enough, not going away" 
    198203                return 0 
    199204        } 
     
    201206        if {$bMotionInfo(away) == 1} { 
    202207                #away, don't do anything (and don't do randomstuff) 
     208                bMotion_putloglev d * "I'm already away, not going away again" 
    203209                return 0 
    204210        } 
     
    208214                bMotionSetRandomAway 
    209215                return 1 
     216        } else { 
     217                bMotion_putloglev d * "All channels are idle, not going away though" 
    210218        } 
    211219 
     
    220228        global BMOTION_SLEEP 
    221229 
     230        bMotion_putloglev 4 * "doRandomStuff" 
     231 
    222232        set saidChannels [list] 
    223233        set silentChannels [list] 
     
    233243        set temp [expr [rand $upperLimit] + $bMotionInfo(minRandomDelay)] 
    234244        timer $temp doRandomStuff 
    235         bMotion_putloglev d * "bMotion: randomStuff next ($temp minutes)" 
     245        bMotion_putloglev d * "bMotion: randomStuff next in $temp minutes" 
    236246 
    237247        # don't bother if we're asleep 
     
    244254 
    245255        if [bMotion_random_away] { 
    246         # we went away, so stop here 
     256                # we went away, so stop here 
     257                bMotion_putloglev d * "we went away, returning from doRandomStuff" 
    247258                return 
    248259        } 
    249260 
    250261        if {$bMotionInfo(away) == 1} { 
    251         #away and busy again, return 
     262                #away and busy again, return 
     263                bMotion_putloglev d * "was away, setting myself back" 
    252264                bMotionSetRandomBack 
    253265        } 
    254266 
    255267        if {[bMotion_setting_get "bitlbee"] == "1"} { 
     268                bMotion_putloglev d * "aborting randomstuff, don't do it in bitlbee mode" 
    256269                return 0 
    257270        } 
     
    329342proc bMotionSetRandomAway {} { 
    330343        global randomAways bMotionInfo bMotionSettings bMotionChannels 
     344        bMotion_putloglev 4 * "bMotionSetRandomAway" 
    331345 
    332346        set awayReason [bMotion_abstract_get "randomAways"] 
     
    348362        #set myself back 
    349363        global bMotionInfo bMotionSettings bMotionChannels 
     364        bMotion_putloglev 4 * "bMotionSetRandomBack" 
    350365 
    351366        bMotion_update_chanlist 
     
    353368        set bMotionInfo(away) 0 
    354369        set bMotionInfo(silence) 0 
     370        bMotion_putloglev d * "No longer silent or away" 
    355371        foreach channel $bMotionChannels { 
    356372                if {[lsearch $bMotionSettings(noAwayFor) $channel] == -1} { 
  • trunk/plugins/admin_general.tcl

    r963 r1004  
    11# bMotion admin plugins 
    22# 
    3 # 
    4 # $Id$ 
    5 # 
    63 
    74############################################################################### 
    85# This is a bMotion plugin 
    9 # Copyright (C) James Michael Seward 2000-2002 
     6# Copyright (C) James Michael Seward 2000-2009 
    107# 
    118# This program is covered by the GPL, please refer the to LICENCE file in the 
     
    2421bMotion_plugin_add_management "interbot" "^interbot" n bMotion_plugin_management_interbot "any" bMotion_plugin_management_interbot_help 
    2522bMotion_plugin_add_management "flux" "^flux capacitors?" n bMotion_plugin_management_flux "any" 
     23bMotion_plugin_add_management "away" "^away" n bMotion_plugin_management_away "any" bMotion_plugin_management_away_help 
    2624 
    2725################################################################################################################################# 
     
    6765        bMotion_putadmin "Random stuff happens at least every [bMotion_setting_get minRandomDelay]min, at most every [bMotion_setting_get maxRandomDelay]min, and not if channel quiet for more than [bMotion_setting_get maxIdleGap]min. Active channels have a line in the last [bMotion_setting_get active_idle_sec]sec." 
    6866        if [bMotion_setting_get silence] { 
    69                 bMotion_putadmin "Running silent" 
     67                bMotion_putadmin "I am silent." 
     68        } 
     69        if [bMotion_setting_get "away"] { 
     70                bMotion_putadmin "I am away." 
    7071        } 
    7172 
     
    313314                } 
    314315} 
     316 
     317proc bMotion_plugin_management_away { handle { text "" } } { 
     318        global bMotionInfo 
     319 
     320        if {$text == ""} { 
     321                if {$bMotionInfo(away)} { 
     322                        bMotion_putadmin "I am currently away." 
     323                } else { 
     324                        bMotion_putadmin "I am not away." 
     325                        } 
     326                return 
     327        } 
     328 
     329        if {$text == "off"} { 
     330                bMotion_putadmin "Coming back from being away." 
     331                set bMotionInfo(away) 0 
     332                set bMotionInfo(silent) 0 
     333                return 
     334        } 
     335 
     336        bMotion_putadmin "Use: .bmotion away [off]" 
     337} 
     338 
     339proc bMotion_plugin_management_away_help { } { 
     340        bMotion_putadmin "Check and adjust the bot's away status" 
     341        bMotion_putadmin "  .bmotion away" 
     342        bMotion_putadmin "    Show if the bot is away or not" 
     343        bMotion_putadmin "  .bmotion away off" 
     344        bMotion_putadmin "    Make the bot be not-away" 
     345} 
     346 
Note: See TracChangeset for help on using the changeset viewer.