######################################
# Away.tcl by KuNgFo0 (www.eggfaq.com)
set away_version "0.4"
#DESCRIPTION At random intervals, sets the bot away/back and sends an away message to the set channels.
#CHANGELOG
# V0.4 ToM @ irc.MindForge.org
# Reindented code. Rewrote the onload putlog. Renamed conf vars to away_cfg(var).
# Added a public channels configuration
# Added a "putserv away" on init so the bot returns from away on rehash.
# Set the next line if you want to display public away/back messages [0/1]
set away_cfg(public) 1
# Set the channels where the bot tells he's away
set away_cfg(publicchans) "#channel"
# Set the next line as the maximum minute interval between away/back
set away_cfg(awaymaxtime) 140
# Set the next list as the away messages you want
set away_cfg(awaymsgs) {
"Reason 1"
"Reason 2"
"Reason 3"
"Reason 4"
"Reason 5"
}
## end config
proc time_away {} {
global away_cfg away_status
if {$away_status(isaway)} {
if {$away_cfg(public)} {
foreach chan [channels] {
# chan auth
if {$away_cfg(publicchans) != ""} {
if {[lsearch -exact [split $away_cfg(publicchans)] [string tolower $chan]] != -1} {
puthelp "PRIVMSG $chan :\001ACTION is \002Back:\002 $away_status(msg) - \002Gone:\002 [expr ([clock seconds] - $away_status(gonetime)) / 60] minutes\001"
}
}
}
}
putserv "AWAY"
set away_status(isaway) 0
} else {
set away_status(msg) [lindex $away_cfg(awaymsgs) [rand [llength $away_cfg(awaymsgs)]]]
if {$away_cfg(public)} {
foreach chan [channels] {
# chan auth
if {$away_cfg(publicchans) != ""} {
if {[lsearch -exact [split $away_cfg(publicchans)] [string tolower $chan]] != -1} {
puthelp "PRIVMSG $chan :\001ACTION is \002Away:\002 $away_status(msg)\001"
}
}
}
}
putserv "AWAY :$away_status(msg)"
set away_status(isaway) 1
set away_status(gonetime) [clock seconds]
}
if {![string match "*time_away*" [timers]]} {
timer [expr [rand $away_cfg(awaymaxtime)] + 1] time_away
}
}
# Init
putserv "AWAY"
set away_status(isaway) 0
set away_status(msg) ""
set away_status(gonetime) 0
if {![string match "*time_away*" [timers]]} {
timer [expr [rand $away_cfg(awaymaxtime)] + 1] time_away
}
putlog "Away.tcl v$away_version by KuNgFo0 mod ToM loaded"