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 

Grabbing Users From Foreach

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
CoMMy
Halfop


Joined: 24 Jul 2003
Posts: 99
Location: Cyprus

PostPosted: Thu Apr 15, 2004 5:58 am    Post subject: Grabbing Users From Foreach Reply with quote

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
View user's profile Send private message
ppslim
Revered One


Joined: 23 Sep 2001
Posts: 3914
Location: Liverpool, England

PostPosted: Thu Apr 15, 2004 6:48 am    Post subject: Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
CoMMy
Halfop


Joined: 24 Jul 2003
Posts: 99
Location: Cyprus

PostPosted: Thu Apr 15, 2004 7:44 am    Post subject: Reply with quote

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
View user's profile Send private message
ppslim
Revered One


Joined: 23 Sep 2001
Posts: 3914
Location: Liverpool, England

PostPosted: Thu Apr 15, 2004 8:00 am    Post subject: Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
CoMMy
Halfop


Joined: 24 Jul 2003
Posts: 99
Location: Cyprus

PostPosted: Thu Apr 15, 2004 9:00 am    Post subject: Reply with quote

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 Razz
_________________
(c) CoMMy (c)
Resistance is Futile!!
We Are The Borg!!
Back to top
View user's profile Send private message
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Thu Apr 15, 2004 11:41 am    Post subject: Something like this? Reply with quote

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
View user's profile Send private message
CoMMy
Halfop


Joined: 24 Jul 2003
Posts: 99
Location: Cyprus

PostPosted: Fri Apr 16, 2004 7:40 am    Post subject: Reply with quote

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
View user's profile Send private message
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Fri Apr 16, 2004 12:09 pm    Post subject: Reply with quote

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 Smile
_________________
Have you ever read "The Manual"?
Back to top
View user's profile Send private message
CoMMy
Halfop


Joined: 24 Jul 2003
Posts: 99
Location: Cyprus

PostPosted: Fri Apr 16, 2004 1:12 pm    Post subject: Reply with quote

I dont understand. Can you elaborate please?
_________________
(c) CoMMy (c)
Resistance is Futile!!
We Are The Borg!!
Back to top
View user's profile Send private message
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Fri Apr 16, 2004 1:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
CoMMy
Halfop


Joined: 24 Jul 2003
Posts: 99
Location: Cyprus

PostPosted: Sat Apr 17, 2004 3:48 am    Post subject: Reply with quote

Many Thanks user.

That did the job done.

Thanks again
_________________
(c) CoMMy (c)
Resistance is Futile!!
We Are The Borg!!
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive 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