| View previous topic :: View next topic |
| Author |
Message |
tueb Halfop
Joined: 04 Oct 2007 Posts: 76 Location: #quiz.de @ irc.gamesurge.net
|
Posted: Sun Oct 18, 2009 5:43 pm Post subject: [SOLVED]check if some mentioned by an user is in the channel |
|
|
Hi,
I need to check a string (with more than one word in it) if it contains a nick of someone in the channel.
for example: $string could be "tueb: are you there?"
and i want to know if someone with the nick "tueb", "are", "you" or "there" is in the chan.
thanks,
tueb _________________ #Quiz.de @ irc.GameSurge.net
JavaChat
Last edited by tueb on Sun Oct 18, 2009 7:09 pm; edited 1 time in total |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sun Oct 18, 2009 6:46 pm Post subject: |
|
|
| Code: | 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
}
} |
This is taken from the fully automated away detection script I wrote awhile back. This should work for you.  _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
tueb Halfop
Joined: 04 Oct 2007 Posts: 76 Location: #quiz.de @ irc.gamesurge.net
|
Posted: Sun Oct 18, 2009 7:09 pm Post subject: |
|
|
great, thx! _________________ #Quiz.de @ irc.GameSurge.net
JavaChat |
|
| Back to top |
|
 |
|