Ticket #159 (closed defect: fixed)

Opened 7 months ago

Last modified 6 months ago

bMotion_random_away fix -- Johno Crawford

Reported by: bmotion Owned by: james
Priority: major Milestone: 0.2.0
Component: core modules Version: 0.1.0
Keywords: Cc:

Description

When randomly going away the bot comes back immediately, below mods in bMotion_random_away procedure should do the trick :)

proc bMotion_random_away {} {

global bMotionLastEvent bMotionChannels bMotionInfo

set timeNow [clock seconds]

# check if it's worth doing anything if {[bMotion_setting_get "bitlbee"]} {

#never go away in bitlbee return 0

}

#override if we should never go away if {[bMotion_setting_get "useAway"] != 1} {

return 0

}

# find the least idle channel set mostRecent 0 set line "comparing idle times: " foreach channel $bMotionChannels {

catch {

append line "$channel=$bMotionLastEvent($channel) " if {$bMotionLastEvent($channel) > $mostRecent} {

set mostRecent $bMotionLastEvent($channel)

}

}

}

set gapTime [expr { int($bMotionInfo(maxIdleGap) * 10) }] bMotion_putloglev 1 * "bMotion: most recent: $mostRecent .. timenow $timeNow .. gap $gapTime"

if {($timeNow - $mostRecent) < $gapTime} {

return 0

}

if {$bMotionInfo(away) == 1} {

#away, don't do anything (and don't do randomstuff) return 0

}

if {[rand 4] == 0} {

putlog "bMotion: All channels are idle, going away" bMotionSetRandomAway return 1

}

return 0

}

Change History

Changed 7 months ago by bmotion

Better formatted..

proc bMotion_random_away {} {
        global bMotionLastEvent bMotionChannels bMotionInfo

        set timeNow [clock seconds]

        # check if it's worth doing anything
        if {[bMotion_setting_get "bitlbee"]} {
                #never go away in bitlbee
                return 0
        }

        #override if we should never go away
        if {[bMotion_setting_get "useAway"] != 1} {
                return 0
        }

        # find the least idle channel
        set mostRecent 0
        set line "comparing idle times: "
        foreach channel $bMotionChannels {
                catch {
                        append line "$channel=$bMotionLastEvent($channel) "
                        if {$bMotionLastEvent($channel) > $mostRecent} {
                                set mostRecent $bMotionLastEvent($channel)
                        }
                }
        }

        set gapTime [expr { int($bMotionInfo(maxIdleGap) * 10) }]
        bMotion_putloglev 1 * "bMotion: most recent: $mostRecent .. timenow $timeNow .. gap $gapTime"

        if {($timeNow - $mostRecent) < $gapTime} {
                return 0
        }

        if {$bMotionInfo(away) == 1} {
                #away, don't do anything (and don't do randomstuff)
                return 0
        }

        if {[rand 4] == 0} {
                putlog "bMotion: All channels are idle, going away"
                bMotionSetRandomAway
                return 1
        }

        return 0
}

Changed 6 months ago by james

  • status changed from new to closed
  • resolution set to fixed

Applied, thanks :)

Note: See TracTickets for help on using tickets.