| View previous topic :: View next topic |
| Author |
Message |
CoMMy Halfop

Joined: 24 Jul 2003 Posts: 99 Location: Cyprus
|
Posted: Thu Apr 15, 2004 5:58 am Post subject: Grabbing Users From Foreach |
|
|
Hey Guys,
I need you assistance on this.
When you do a | Code: | | foreach user [chanlist $chan] { | The users are listed like this in the bot in seperate lines.
user1
user2
user3
user4
How can i grab each user seperately? I know its not [lindex] because their not on the same line. What is the command ? _________________ (c) CoMMy (c)
Resistance is Futile!!
We Are The Borg!!
Last edited by CoMMy on Thu Apr 15, 2004 9:02 am; edited 1 time in total |
|
| Back to top |
|
 |
ppslim Revered One
Joined: 23 Sep 2001 Posts: 3914 Location: Liverpool, England
|
Posted: Thu Apr 15, 2004 6:48 am Post subject: |
|
|
The "chanlist" command returns a list of users that you can use lindex on.
What exactly are you trying to do, as you seem to be confusing how to operate lists. _________________ PlusNet Supported Customer - Low cost UK ISP services |
|
| Back to top |
|
 |
CoMMy Halfop

Joined: 24 Jul 2003 Posts: 99 Location: Cyprus
|
Posted: Thu Apr 15, 2004 7:44 am Post subject: |
|
|
Well, I have this and it only ops 1 user while there are many in the channel to op.
| Code: |
........
foreach user [chanlist $chan] {
if {![isop $user $chan] && ![matchattr [nick2hand $user $chan] &d $chan]} {
set user0 [lindex $user 0]
set user1 [lindex $user 1]
set user2 [lindex $user 2]
set user3 [lindex $user 3]
set user4 [lindex $user 4]
set user5 [lindex $user 5]
set user6 [lindex $user 6] }}
putserv "MODE $chan +o+o+o+o+o+o $user0 $user1 $user2 $user3 $user4 $user5 $user6"
return 1 }}
|
What is it with this ? _________________ (c) CoMMy (c)
Resistance is Futile!!
We Are The Borg!! |
|
| Back to top |
|
 |
ppslim Revered One
Joined: 23 Sep 2001 Posts: 3914 Location: Liverpool, England
|
Posted: Thu Apr 15, 2004 8:00 am Post subject: |
|
|
OK.
The "chanlist" command spits out a list of nickname on the channel.
The "foreach" command will cycle through each person in a list.
I don't understand why you are trying to do what your doing, as it quite simply isn't thought about. _________________ PlusNet Supported Customer - Low cost UK ISP services |
|
| Back to top |
|
 |
CoMMy Halfop

Joined: 24 Jul 2003 Posts: 99 Location: Cyprus
|
Posted: Thu Apr 15, 2004 9:00 am Post subject: |
|
|
Instead of simply using pushmode $chan +o $user to op everyone
i want to do this fast user putdccraw or putquick, thus i have
to seperate each user into different args.
I hope you understand  _________________ (c) CoMMy (c)
Resistance is Futile!!
We Are The Borg!! |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Thu Apr 15, 2004 11:41 am Post subject: Something like this? |
|
|
| Code: |
proc massmode {chan mode arg} {
scan $mode {%[-+]%[bov]} p m
set j [llength $arg]
set k [expr {${::modes-per-line}-1}]
set out "";
for {set i 0} {$i<$j} {incr i} {
set args [lrange $arg $i [incr i $k]]
append out "MODE $chan $p[string repeat $m [llength $args]] [join $args]\n"
}
putdccraw 0 [string len $out] $out
}
# then
massmode #yourchan -o [chanlist #yourchan];#;) |
_________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
CoMMy Halfop

Joined: 24 Jul 2003 Posts: 99 Location: Cyprus
|
Posted: Fri Apr 16, 2004 7:40 am Post subject: |
|
|
My God.
Thanks user that works fine but there is one more thing.
I used to use
| Code: | foreach user [chanlist $chn] {
set hand [nick2hand $user $chn]
if {![isop $user $chn] || [matchattr $hand n] || [matchattr $hand b] || [matchattr $hand m] || $user == $botnick || [onchansplit $user $chn]} {continue}
pushmode $chn -o $user }} |
and i used to specify which users to deop with this code:
| Code: | | if {![isop $user $chn] || [matchattr $hand n] || [matchattr $hand b] || [matchattr $hand m] || $user == $botnick || [onchansplit $user $chn]} {continue} |
but now i dont know how to specify this with your "massmode" proc.
Can you explain how to do this using your proc ?
Thanks _________________ (c) CoMMy (c)
Resistance is Futile!!
We Are The Borg!! |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Fri Apr 16, 2004 12:09 pm Post subject: |
|
|
instead of 'pushmode', just 'lappend' the nicks to a variable and pass the resulting list to 'massmode' after the foreach loop. Or do a total rewrite of the massmode proc to include your rules  _________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
CoMMy Halfop

Joined: 24 Jul 2003 Posts: 99 Location: Cyprus
|
Posted: Fri Apr 16, 2004 1:12 pm Post subject: |
|
|
I dont understand. Can you elaborate please? _________________ (c) CoMMy (c)
Resistance is Futile!!
We Are The Borg!! |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Fri Apr 16, 2004 1:43 pm Post subject: |
|
|
| Code: | set deop {}
foreach user [chanlist $chn] {
if {[isop $user $chn]&&![matchattr [nick2hand $user $chn] nmb]&&\
![isbotnick $user]&&![onchansplit $user $chn]} {
lappend deop $user
}
}
massmode $chn -o $deop |
_________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
CoMMy Halfop

Joined: 24 Jul 2003 Posts: 99 Location: Cyprus
|
Posted: Sat Apr 17, 2004 3:48 am Post subject: |
|
|
Many Thanks user.
That did the job done.
Thanks again _________________ (c) CoMMy (c)
Resistance is Futile!!
We Are The Borg!! |
|
| Back to top |
|
 |
|