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 

getting problem with matching pattern.

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
honeybee
Halfop


Joined: 01 Jan 2006
Posts: 80

PostPosted: Mon May 08, 2006 10:19 pm    Post subject: getting problem with matching pattern. Reply with quote

Hey,
I'm again stuck with a part of my tcl.
i m trying to get info from userlist and matchin it with the $uhost and if it doesnt match do something. I don't think i m doing it correctly.

Code:
foreach user [userlist ] {
  foreach host [getuser $user hosts] {
     if {![string match -nocase $host $uhost]} { do something }
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue May 09, 2006 2:03 am    Post subject: Reply with quote

$uhost means user@host, i.e. no nick; whereas userfile record's HOSTS list is interpreted as consisting of full hostmasks, i.e. nick!user@host

so you need to use *!$uhost instead of $uhost

or use [finduser]
_________________
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
honeybee
Halfop


Joined: 01 Jan 2006
Posts: 80

PostPosted: Tue May 09, 2006 5:21 am    Post subject: Reply with quote

well, i cant use [finduser] cause i want to match *!@$uhost against all the hosts of particular flag let it be +f like [userlist f|f $chan] or something. and if that nick is a validuser [validuser $nick] and his/her *!@$uhost doesnt match with our particular flag's host { do soemthing }, thats what i want to do.
Back to top
View user's profile Send private message
honeybee
Halfop


Joined: 01 Jan 2006
Posts: 80

PostPosted: Tue May 09, 2006 3:39 pm    Post subject: Reply with quote

any help please?
Back to top
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Wed May 10, 2006 6:34 am    Post subject: Reply with quote

hosts are not "user.domain.com" but "*!*@user.domain.com" therefore you need to at least match against "!$uhost". Without ! there will be no match. And if you want to completly ignore any possible entries in host for idents then split them off using [lindex [split $host @] 1].
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
honeybee
Halfop


Joined: 01 Jan 2006
Posts: 80

PostPosted: Wed May 10, 2006 6:32 pm    Post subject: Reply with quote

Ok fine, [lindex [split $uhost @] 1] will return with the host and then i match it with the
Code:
set host "[lindex [split $uhost @] 1]"
foreach user [userlist o] {
foreach userhost [getuser $user hosts] {![string match -nocase $userhost $host]} { do something }

and i aslo want to ask foreach user [userlist o] { putlog "[getuser $user hosts]"} it returns hosts of the respective flags, is it a string or something or should i use it in "" here
Quote:
![string match -nocase "$userhost" $host]
Back to top
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Wed May 10, 2006 8:18 pm    Post subject: Reply with quote

your quoted line will most likely never be compiled because
a) foreach uses 3 arguments only
b) there is no function called 0 or 1 (you are missing some conditional structure)

PS: you still have a string match that will never be true, because the pattern contains string parts that $host can never ever have.

Edit: then you will get the split string match line as addionatl list elements @_o
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...


Last edited by De Kus on Thu May 11, 2006 4:05 am; edited 2 times in total
Back to top
View user's profile Send private message MSN Messenger
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Wed May 10, 2006 8:51 pm    Post subject: Reply with quote

De Kus wrote:
a) foreach uses 3 arguments only

Not necessarily:
Quote:
NAME

foreach - Iterate over all elements in one or more lists

SYNOPSIS

foreach varname list body
foreach varlist1 list1 ?varlist2 list2 ...? body

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
honeybee
Halfop


Joined: 01 Jan 2006
Posts: 80

PostPosted: Thu May 11, 2006 7:37 pm    Post subject: Reply with quote

Ok thanks i did it myself.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests 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