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.

Creating an access list

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
J
JC^
Voice
Posts: 4
Joined: Fri May 25, 2007 1:43 pm

Creating an access list

Post by JC^ »

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?
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

you can use a foreach loop on the userlist, and use matchattr to determine the modes the user has.

Code: Select all

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
J
JC^
Voice
Posts: 4
Joined: Fri May 25, 2007 1:43 pm

Post by JC^ »

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

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:
- 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?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

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)."
}
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

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

Owners:
user1
user2
user3
Instead of:

Code: Select all

Owners:
user1, user2, user3

Code: Select all

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
J
JC^
Voice
Posts: 4
Joined: Fri May 25, 2007 1:43 pm

Thanks

Post by JC^ »

THANKS!!!

You both are GENIUSES! Tosser^^'s code worked best for me.
Post Reply