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
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
}
etc.OWNER - bob
COOWNER - ian
MANAGER - spud
OP
HALFOP
VOICE
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: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"
}
}
}
because its going through each flag. Is there any way i could overcome this?-E- OWNER - Simon
-E- MANAGER - Simon
-E- OP - 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.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:
because its going through each flag. Is there any way i could overcome this?-E- OWNER - Simon
-E- MANAGER - Simon
-E- OP - Simon
thanks
Simon
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
}
}
}