| View previous topic :: View next topic |
| Author |
Message |
JC^ Voice
Joined: 25 May 2007 Posts: 4
|
Posted: Fri May 25, 2007 1:56 pm Post subject: Creating an access list |
|
|
I've searched everywhere for the know-how and help, but can't find it, so I am posting here in the hopes that someone can help me.
I am attempting to write my own script, basically taking over channel access from chanserv, allowing eggy to give AOP, SOP and Owner.
I've done everything (including auto-op on join) by myself, but now what I want is the ability to list users (or actually user records) that have specific eggy modes (like m n and o).
I know it involves the match command because I can get what I want in the party line, and if I have to, I can just stick with that, but I would like to have a public command for it.
Here is an example of the command:
!list aop - displays a list of all user records with the o mode
!list sop - displays a list of all user records with the m mode
!list owner - displays a list of all user records with the n mode
The output doesn't have to be fancy, just nick and host.
Can someone assist me? |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Fri May 25, 2007 2:09 pm Post subject: |
|
|
you can use a foreach loop on the userlist, and use matchattr to determine the modes the user has.
| Code: | foreach user [userlist #channel |(n for owner, m for sop, o for aop, nmo for all)] {
#for aop
if {[matchattr $user |o #channel] && ![matchattr $user |n #channel] && [matchattr $user |m #channel]} {
# user has aop access
}
#for sop
if {[matchattr $user |m #channel] && ![matchattr $user |n #channel]} {
# user has sop access
}
#for owner
if {[matchattr $user |n #channel]} {
# user has owner access
}
} |
Thats just a basebone, you can build on this...
Hope this helps  _________________ r0t3n @ #r0t3n @ Quakenet |
|
| Back to top |
|
 |
JC^ Voice
Joined: 25 May 2007 Posts: 4
|
Posted: Sat May 26, 2007 6:48 am Post subject: |
|
|
Thanks Tosser^^... After looking over some other posts in the forum as well as this one, I've made a list that works, but I'd like the output to be a bit different.
Here is the code:
| Code: | proc proc_getlist {nick uhost hand chan arg} {
putserv "NOTICE $nick :Users in $chan access list:"
set total(owner) 0
set total(sop) 0
set total(aop) 0
set total(Total) 0
foreach user [userlist] {
incr total(Total)
if {[matchattr $user |n $chan]} {
lappend users "$user (Owner),"
incr total(owner)
} elseif {[matchattr $user |m $chan]} {
lappend users "$user (SOP),"
incr total(sop)
} elseif {[matchattr $user |o $chan]} {
lappend users "$user (AOP),"
incr total(aop)
}
}
if {[llength $users]} {
putserv "NOTICE $nick :[string trimright [join $users] ,]"
}
putserv "NOTICE $nick :Total: $total(Total) Owner: $total(owner), SOP: $total(sop), AOP: $total(aop)."
}
|
Currently the output is:
| Quote: | - Users in #Main access list:
- Dorian (Owner), JC^ (AOP)
- Total: 2 Owner: 1, SOP: 0, AOP: 1. |
And I'd like to change the output to something a bit more vertical:
Owners:
Dorian
SOP:
None
AOP:
JC^
Total: 2 Owner: 1, SOP: 0, AOP: 1.
Can someone assist? |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat May 26, 2007 9:12 am Post subject: |
|
|
| Code: | proc proc_getlist {nick uhost hand chan arg} {
putserv "NOTICE $nick :Users in $chan access list:"
array set total {
owner 0
sop 0
aop 0
Total 0
}
foreach user [userlist] {
incr total(Total)
if {[matchattr $user |n $chan]} {
lappend users(Owner) $user
incr total(owner)
} elseif {[matchattr $user |m $chan]} {
lappend users(SOp) $user
incr total(sop)
} elseif {[matchattr $user |o $chan]} {
lappend users(AOp) $user
incr total(aop)
}
}
foreach {t u} [array get users] {
putserv "NOTICE $nick :${t}(s): [join $u {, }]"
}
putserv "NOTICE $nick :Total: $total(Total) Owner: $total(owner), SOP: $total(sop), AOP: $total(aop)."
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Sat May 26, 2007 5:28 pm Post subject: |
|
|
I would believe this would work better than Sir_Fz's code if you want it to display as a list instead of side by side.
Example:
| Code: | Owners:
user1
user2
user3 |
Instead of:
| Code: | Owners:
user1, user2, user3 |
| Code: | proc proc_getlist {nick host hand chan arg} {
putserv "NOTICE $nick :Users in $chan access list:"
set owner ""
set sop ""
set aop ""
set total 0
foreach user [userlist $chan |nmo] {
if {[matchattr $user |n $chan]} {
lappend owner $user
incr total
} elseif {[matchattr $user |m $chan]} {
lappend sop $user
incr total
} elseif {[matchattr $user |o $chan]} {
lappend aop $user
incr total
}
}
putserv "NOTICE $nick :Owner(s):"
foreach user $owner {
putserv "NOTICE $nick :$user"
}
putserv "NOTICE $nick :[format %-15s ""]"
putserv "NOTICE $nick :SOP:"
foreach user $sop {
putserv "NOTICE $nick :$user"
}
putserv "NOTICE $nick :[format %-15s ""]"
putserv "NOTICE $nick :AOP:
foreach user $aop {
putserv "NOTICE $nick :$user"
}
putserv "NOTICE $nick :Total: $total, Owner: [llength $owner], SOP: [llength $sop], AOP: [llength $aop]."
} |
_________________ r0t3n @ #r0t3n @ Quakenet |
|
| Back to top |
|
 |
JC^ Voice
Joined: 25 May 2007 Posts: 4
|
Posted: Sun May 27, 2007 5:23 am Post subject: Thanks |
|
|
THANKS!!!
You both are GENIUSES! Tosser^^'s code worked best for me. |
|
| Back to top |
|
 |
|
|
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
|
|