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.

results

Help for those learning Tcl or writing their own scripts.
Post Reply
a
ap
Halfop
Posts: 44
Joined: Fri Jun 09, 2006 12:20 am

results

Post by ap »

Hi, I am going thorugh the chanlist to save the userslist to the variable if they have a undernet host, if they don't have a undernet host then i don't save it.
I am using the following codes but sometime it missed some undernet hosts and sometime it works fine. Is there any better way to do it? thanks

Code: Select all

foreach user [chanlist $chan]] {
     set userhost [getchanhost $user $chan]
      if {[string match "*.users.undernet.org" $userhost]} {
	     set h [lindex $userhost [lsearch -glob $userhost *.users.undernet.org]]
	} else { 
	     set h "N/A"
      }
User avatar
krimson
Halfop
Posts: 86
Joined: Wed Apr 19, 2006 8:12 am

Post by krimson »

well, what your code does there is check each host if it matches *.users.undernet.org and overwrites the variable $h until the last user to be checked.

i'm not sure what you want to do with this, so if you'd be more specific i could help out with some code
a
ap
Halfop
Posts: 44
Joined: Fri Jun 09, 2006 12:20 am

Post by ap »

well i am going thorugh the chanlist and i check if user has undernet host, if yes then i save to a variable, in the above code i set that to "h", if no then i move "n/a" but there must be the better way. i think something is fishy in the above codes because bot doesn't check his host even that's undernet host. i need the codes so it check the chanlist and it should check if user has a undernost host, if yes then write to the variaable if not then write "n/a"
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

There are quite a few flaws in that code:
1. You iterate through all members of a channel, doing that check; but each time you overwrite the result of the previous test.. Unless you use $h further down inside that foreach-loop, that would not make sense

2. You are mixing lists and string commands; this is a BIG no-do. If you wish to use list-commands, you'll have to convert the string to a list, using commands such as "list" or "split".

If you wish to isolate the hostname part from nick!ident@hostname, I'd suggest something like this:

Code: Select all

...
set userhost [getchanhost $user $chan]
if {[string match "*.users.undernet.org" $userhost]} {
  set h [lindex [split $userhost "@"] end]
} ...
Of course, you'd still have to do something useful with $h before you close the foreach-loop...

edit: Removed an accidental space between $ and userhost in the example-code
Last edited by nml375 on Mon Aug 07, 2006 11:28 am, edited 1 time in total.
NML_375
a
ap
Halfop
Posts: 44
Joined: Fri Jun 09, 2006 12:20 am

Post by ap »

thank you , but how do i get ident@host
set userhost [getchanhost $user $chan]
if {[string match "*.users.undernet.org" $ userhost]} {
set h [lindex [split $userhost "@"] end]
} ...
User avatar
krimson
Halfop
Posts: 86
Joined: Wed Apr 19, 2006 8:12 am

Post by krimson »

Code: Select all

set userhost [getchanhost $user $chan]
this provides you the ident@host part
Post Reply