proc check_nick {nick uhost hand chan text} {
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]} {
# checknick is in the channel
# do stuff with $::checknick inside this proc or invoke
# another procedure, keep in mind:
# $::checknick will be the nickname found
# $::checkchan will be the channel this was issued in
}
}