egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
tueb
Halfop


Joined: 04 Oct 2007
Posts: 76
Location: #quiz.de @ irc.gamesurge.net

PostPosted: Sun Oct 18, 2009 5:43 pm    Post subject: [SOLVED]check if some mentioned by an user is in the channel Reply with quote

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
View user's profile Send private message Visit poster's website
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sun Oct 18, 2009 6:46 pm    Post subject: Reply with quote

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. Wink
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
tueb
Halfop


Joined: 04 Oct 2007
Posts: 76
Location: #quiz.de @ irc.gamesurge.net

PostPosted: Sun Oct 18, 2009 7:09 pm    Post subject: Reply with quote

great, thx!
_________________
#Quiz.de @ irc.GameSurge.net
JavaChat
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber