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.

Grabbing Users From Foreach

Old posts that have not been replied to for several years.
Locked
User avatar
CoMMy
Halfop
Posts: 99
Joined: Thu Jul 24, 2003 1:03 am
Location: Cyprus

Grabbing Users From Foreach

Post by CoMMy »

Hey Guys,

I need you assistance on this.

When you do a

Code: Select all

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 ?
Last edited by CoMMy on Thu Apr 15, 2004 9:02 am, edited 1 time in total.
(c) CoMMy (c)
Resistance is Futile!!
We Are The Borg!!
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

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.
User avatar
CoMMy
Halfop
Posts: 99
Joined: Thu Jul 24, 2003 1:03 am
Location: Cyprus

Post by CoMMy »

Well, I have this and it only ops 1 user while there are many in the channel to op.

Code: Select all

........
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!!
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

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.
User avatar
CoMMy
Halfop
Posts: 99
Joined: Thu Jul 24, 2003 1:03 am
Location: Cyprus

Post by CoMMy »

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 :P
(c) CoMMy (c)
Resistance is Futile!!
We Are The Borg!!
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Something like this?

Post by user »

Code: Select all

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"?
User avatar
CoMMy
Halfop
Posts: 99
Joined: Thu Jul 24, 2003 1:03 am
Location: Cyprus

Post by CoMMy »

My God.
Thanks user that works fine but there is one more thing.

I used to use

Code: Select all

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: Select all

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!!
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

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"?
User avatar
CoMMy
Halfop
Posts: 99
Joined: Thu Jul 24, 2003 1:03 am
Location: Cyprus

Post by CoMMy »

I dont understand. Can you elaborate please?
(c) CoMMy (c)
Resistance is Futile!!
We Are The Borg!!
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Code: Select all

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"?
User avatar
CoMMy
Halfop
Posts: 99
Joined: Thu Jul 24, 2003 1:03 am
Location: Cyprus

Post by CoMMy »

Many Thanks user.

That did the job done.

Thanks again
(c) CoMMy (c)
Resistance is Futile!!
We Are The Borg!!
Locked