| View previous topic :: View next topic |
| Author |
Message |
ap Halfop
Joined: 09 Jun 2006 Posts: 44
|
Posted: Sun Aug 06, 2006 1:58 pm Post subject: results |
|
|
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: | 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"
} |
|
|
| Back to top |
|
 |
krimson Halfop

Joined: 19 Apr 2006 Posts: 86
|
Posted: Sun Aug 06, 2006 2:31 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
ap Halfop
Joined: 09 Jun 2006 Posts: 44
|
Posted: Sun Aug 06, 2006 2:37 pm Post subject: |
|
|
| 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" |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Aug 06, 2006 3:25 pm Post subject: |
|
|
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: |
...
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 _________________ NML_375, idling at #eggdrop@IrcNET
Last edited by nml375 on Mon Aug 07, 2006 11:28 am; edited 1 time in total |
|
| Back to top |
|
 |
ap Halfop
Joined: 09 Jun 2006 Posts: 44
|
Posted: Sun Aug 06, 2006 6:08 pm Post subject: |
|
|
thank you , but how do i get ident@host
| Quote: | set userhost [getchanhost $user $chan]
if {[string match "*.users.undernet.org" $ userhost]} {
set h [lindex [split $userhost "@"] end]
} ... |
|
|
| Back to top |
|
 |
krimson Halfop

Joined: 19 Apr 2006 Posts: 86
|
Posted: Mon Aug 07, 2006 3:01 am Post subject: |
|
|
| Quote: | | Code: | | set userhost [getchanhost $user $chan] |
|
this provides you the ident@host part |
|
| Back to top |
|
 |
|