Provides anti-idle functionality in sBNC. If enabled, the idle-time of that user will be reset if exceeding X seconds, or randomly. Definable through commands.
Internally a central timer is started when aidle.tcl is loaded. Every 30 seconds it will check what users have the feature enabled, and reset their idle-time if it has exceeded their set value. This means you may be idle for up to 30 seconds more than the value you define.
| Software | Version | Details |
|---|---|---|
| sBNC (w/TCL module) | 1.1 | Developed and tested on 1.1-371. |
| Latest version: | Build 4 (2006-12-02) | .zip (1.2kB) |
|---|---|---|
| Previous versions: | Available per request. | |
aidle.tcl in scripts/source scripts/aidle.tcl to sbnc.tclDefault syntax:
/sbnc set antiidle <off|1|N>
off will turn it off.1 will reset your idle-time randomly. Though keep it under 10 minutes.N is number of seconds to have as maximum idle-time (between 59 and 18001).
If you are using sBNC 1.1, the
antiidle setting will randomly not be listed if you do /sbnc set. The reason for this is believed to have something to do with an inaccurate timers bug fixed in 1.2beta - If this happens to you in 1.2, please let me know.
Update: Fixed in Build 2 by using internaltimer instead of utimer.
If you are getting the replies twice when setting your anti-idle settings, after updating from Build 3 to Build 4, it is because I started using TCL namespaces from Build 4. To remove the old triggers either reload1) the TCL module or use the following 3 commands to clean up the old binds and timer:
/sbnc tcl internalunbind command aidle:commands /sbnc tcl internalunbind server aidle:catch /sbnc tcl internalkilltimer aidle:reset
Note that this source will/should be the development version, i.e. all changes noted in the history section, will have been made in this section.
# # @name aIdle - Anti idle # @version Build 4 (2006-12-02) # @license GPL 2 (http://www.gnu.org/licenses/gpl.html) # @author David Lorentsen <zyberdog@quakenet.org> # @www http://wiki.zyberdog.dk/sbnc:aidle # if {[namespace exists aidle]} { namespace delete aidle } namespace eval aidle { # Initialize variables and arrays variable whois array set whois {} # Binds internalbind command [namespace current]::commands internalbind server [namespace current]::outercept internalbind client [namespace current]::intercept proc commands {client parameters} { set cmd [lindex $parameters 0] if {[string equal -nocase $cmd "set"]} { if {[llength $parameters] < 2} { set cur [getbncuser $client tag antiidle] if {$cur > 59} { set antiidle "On ($cur seconds)" } elseif {$cur == 1} { set antiidle "On (random)" } else { set antiidle "Off" } internaltimer 0 0 [namespace current]::replyset [list $client $antiidle] } elseif {[string equal -nocase [lindex $parameters 1] "antiidle"]} { set value [lindex $parameters 2] if {[string equal -nocase $value "off"] || [string equal -nocase $value "0"]} { setbncuser $client tag antiidle "0" bncreply "Done. Turned off." } elseif {$value > 59} { if {$value > 1800} { set $value 1800 } setbncuser $client tag antiidle $value bncreply "Done. Your idle-time will be reset shortly after it exceeds $value seconds." } elseif {[string equal $value "1"]} { setbncuser $client tag antiidle 1 bncreply "Done. Your idle-time will be reset randomly (between 30 and 600 seconds)." } else { bncreply "Invalid value. Use either; 1 for random, an integer between 59 and 18001 (seconds), or \"off\"." } haltoutput } } } proc outercept {client parameters} { variable whois if {[string equal -nocase [lindex $parameters 1] "PRIVMSG"] && [string equal [lindex [split [lindex $parameters 0] "!"] 0] $::botnick]} { if {[string equal -nocase [lindex $parameters 3] "ANTIIDLE"] && [getbncuser $client tag antiidle] > 0} { haltoutput } } elseif {[string equal [lindex $parameters 2] $::botnick]} { if {[string equal [lindex $parameters 1] "311"]} { set whois($client) 1 internaltimer 1 0 unset [namespace current]::whois($client) } elseif {[string equal [lindex $parameters 1] "301"] && [string equal -nocase [array names whois -exact $client] ""] && [getbncuser $client tag antiidle] > 0} { haltoutput } } } proc intercept {client parameters} { if {[string equal -nocase [lindex $parameters 0] "PRIVMSG"] && ![string equal [lindex $parameters 1] $::botnick]} { setbncuser $client tag antiidle.seen [unixtime] } } proc replyset {reply} { setctx [lindex $reply 0] bncreply "antiidle - [lindex $reply 1]" } proc reset {} { foreach user [bncuserlist] { set value [getbncuser $user tag antiidle] set seen [getbncuser $user tag antiidle.seen] if {[string equal $value "1"]} { if {[rand 10] == 9 || [unixtime] > [expr $seen + 599]} { setctx $user putserv "PRIVMSG $::botnick :ANTIIDLE" setbncuser $user tag antiidle.seen [unixtime] } } elseif {$value > 59 && [unixtime] > [expr $seen + $value]} { setctx $user putserv "PRIVMSG $::botnick :ANTIIDLE" setbncuser $user tag antiidle.seen [unixtime] } } } proc init {} { internaltimer 30 1 [namespace current]::reset } proc unload {} { internalunbind command [namespace current]::commands internalunbind server [namespace current]::outercept internalunbind client [namespace current]::intercept internalkilltimer [namespace current]::reset namespace delete [namespace current] return -code ok \ "aidle.tcl unloaded" } init }
$::botnick to prevent issues with current nick of user.internaltimer instead of utimer to workaround a bug where /sbnc set would not list antiidle the setting.