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.

counting users channel access

Old posts that have not been replied to for several years.
Locked
s
simonbell
Halfop
Posts: 68
Joined: Mon Aug 05, 2002 8:07 pm
Location: Washington, England
Contact:

counting users channel access

Post by simonbell »

Hi

Is it possible to count how many channels a specific handle has +n in? And if so, how can it be done?

thanks
Simon
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

This snippet of code will could how many chans the user has any flag in

Use it like:
countchanflags <hand> <flag>
It will return the number of chans, or * for no such hand (as many functions in eggdrop does.

Code: Select all

proc countchanflags {hand flags} {
  if {![validuser $hand]} { return * }
  set i 0
  foreach a [channels] {
    if {[matchattr $chan "|${flags}" $a]} { incr i }
  }
  return $i
}
Example.
countchanflags ppslim n
s
simonbell
Halfop
Posts: 68
Joined: Mon Aug 05, 2002 8:07 pm
Location: Washington, England
Contact:

Post by simonbell »

ok thanks, i have this working to an extent now. What i am now trying to do is list the handles of people who have access in a particular channel. So someone types .userlist and gets
OWNER - bob
COOWNER - ian
MANAGER - spud
OP
HALFOP
VOICE
etc.

I know the flag for each level and so wrote this script:
proc pub_userlist {nick uhost hand chan text} {
foreach ulist [userlist] {
if { [matchattr $ulist -|n $chan] == 1 } {
putnotc $nick "OWNER - $ulist"
}
if { [matchattr $ulist -|m $chan] == 1 } {
putnotc $nick "MANAGER - $ulist"
}
if { [matchattr $ulist -|o $chan] == 1 } {
putnotc $nick "OP - $ulist"
}
if { [matchattr $ulist -|l $chan] == 1 } {
putnotc $nick "HALFOP - $ulist"
}
if { [matchattr $ulist -|v $chan] == 1 } {
putnotc $nick "VOICE - $ulist"
}
}
}
Now the problem ive encountered is that if someone has an +n flag for a channel, they appear to also be given +om as well, so when i do a .userlist for a channel i own, i get this:
-E- OWNER - Simon
-E- MANAGER - Simon
-E- OP - Simon
because its going through each flag. Is there any way i could overcome this?

thanks
Simon
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

This is simple enough, just expand your matching system. IE, don't simply check for one flag.

If you want to list +o users, but not +m or +n, somthing like this would work

matchattr hand "+o-nm" chan
s
simonbell
Halfop
Posts: 68
Joined: Mon Aug 05, 2002 8:07 pm
Location: Washington, England
Contact:

Post by simonbell »

This does not seem to work:
proc pub_olist {nick uhost hand chan text} {
foreach ulist [userlist] {
if { [matchattr $ulist -|+o-mn $chan] == 1 } {
putnotc $nick "OP - $ulist"
}
}
}
typing .olist on a user with the flags +aom on a channel returns
-E- OP - sajjad
Simon
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

simonbell wrote:ok thanks, i have this working to an extent now. What i am now trying to do is list the handles of people who have access in a particular channel. So someone types .userlist and gets
[snip]
Now the problem ive encountered is that if someone has an +n flag for a channel, they appear to also be given +om as well, so when i do a .userlist for a channel i own, i get this:
-E- OWNER - Simon
-E- MANAGER - Simon
-E- OP - Simon
because its going through each flag. Is there any way i could overcome this?

thanks
Simon
Simon, it seems there are several ways to do it. An alternative approach is to iterate on the list of users and within that iteration iterate on the flags. When a matching flag is found, the innermost iteration (i.e. looking for a matching flag) is stopped.

Example:

Code: Select all

   # the flaglist in order of importance!
   set flaglist {n m o f v}
   # review all users in the userlist
   foreach user [userlist] {
      foreach flag $flaglist {
         # check if user has global or channel access. 
         if {[matchattr $user $flag $chan]} { 
            lappend userswithflag($flag) $user
            break
         }
      }
   }
A skeleton demo is http://members.fortunecity.com/eggheadt ... xs.tcl.txt
Locked