This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

[SOLVED]check if some mentioned by an user is in the channel

Help for those learning Tcl or writing their own scripts.
Post Reply
t
tueb
Halfop
Posts: 76
Joined: Thu Oct 04, 2007 6:09 am
Location: #quiz.de @ irc.gamesurge.net
Contact:

[SOLVED]check if some mentioned by an user is in the channel

Post by tueb »

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
Last edited by tueb on Sun Oct 18, 2009 7:09 pm, edited 1 time in total.
#Quiz.de @ irc.GameSurge.net
JavaChat
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

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. ;)
t
tueb
Halfop
Posts: 76
Joined: Thu Oct 04, 2007 6:09 am
Location: #quiz.de @ irc.gamesurge.net
Contact:

Post by tueb »

great, thx!
#Quiz.de @ irc.GameSurge.net
JavaChat
Post Reply