holycrap wrote:Cool, can't thank you enough!
Anything that will make it works better are welcome.
I don't have that many nick in my channel, don't know if checking every word will slow the bot down or not.
<speechles> i wonder if test123 is here or there or anywhere
<sp33chy> TEST123 is away: this is an away test for egghelp
<speechles> do any of you guys know if that test123 guy is away or anything?
<sp33chy> TEST123 is away: this is an away test for egghelp
<speechles> hey atest123
<speechles> is there anybody heretest123 that can answer a question?
<speechles> test123
<sp33chy> TEST123 is away: this is an away test for egghelp
Code: Select all
# Fully Automated Away Detection by speechles
# Egghelp version v1.0 - tested and working.. yay!!
# Donate to slennox @ egghelp.org if you like this script!
# Fully automatic, you configure nothing.
# The script will decide based upon the length of the nicklist
# or the length of user input on which to scan with, it will
# use whichever is shorter which makes it faster, enjoy.
# SCRIPT begins
# initialize the global variables
variable checknick ""
variable checkchan ""
# flag to control behavior per channel
setudef flag checknames
# bind to raw reply concerning away status of whois
bind RAW -|- 301 checkaway
# bind to everything said in channel
bind pubm -|- * checkcriteria
# check which list is shorter, nicklist or text length
# and use that to scan for similarity and issue the whois
proc checkcriteria {nick uhost hand chan text} {
if {![channel get $chan checknames]} { return }
set ::checkchan $chan
set ::checknick ""
if {[llength [chanlist $chan]] < [llength [split $text]]} {
foreach n [chanlist $chan] {
if {[lsearch [split [string tolower $text]] [string tolower $n]] != -1} {
if {[string equal [string length $n] [string length [lindex [split $text] [lsearch [split [string tolower $text]] [string tolower $n]]]]]} {
set ::checknick $n
break
}
}
}
} else {
foreach n [split $text] {
# the join and split are used to emulate the behavior
# of the -nocase switch which isn't allowed during lsearch
# you can't string tolower a list, hence the join and split ;)
if {[lsearch [split [string tolower [join [chanlist $chan]]]] [string tolower $n]] != -1} {
set ::checknick $n
break
}
}
}
if {[string length $::checknick] > 0 && [onchan $::checknick $chan]} {
putserv "WHOIS $::checknick"
}
}
# interpret the whois request and make sure the nick requested matches
# the whois reply we are searching for. If the person is not away, a 301
# will not be sent, and the whois will be ignored as per requested.
proc checkaway {from key text} {
if {![string match -nocase [lindex [split $text] 1] $::checknick]} { return }
putserv "privmsg $::checkchan :[lindex [split $text] 1] is away: [string range [join [lrange [split $text] 2 end]] 1 end]"
set ::checknick ""
}
putlog "Fully Automated Away Detection loaded."
Remember, to enable it, get on your bots partyline and .chanset #yourchan +checknames
Note: On actually using the script often, I've found it doesn't really lag the bot one bit even running in channels containing thousands of nicknames. It's instantaneous response and even faster than the other code I posted.