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 

Creating an access list

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
JC^
Voice


Joined: 25 May 2007
Posts: 4

PostPosted: Fri May 25, 2007 1:56 pm    Post subject: Creating an access list Reply with quote

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


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Fri May 25, 2007 2:09 pm    Post subject: Reply with quote

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 Smile
_________________
r0t3n @ #r0t3n @ Quakenet
Back to top
View user's profile Send private message MSN Messenger
JC^
Voice


Joined: 25 May 2007
Posts: 4

PostPosted: Sat May 26, 2007 6:48 am    Post subject: Reply with quote

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


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sat May 26, 2007 9:12 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Sat May 26, 2007 5:28 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
JC^
Voice


Joined: 25 May 2007
Posts: 4

PostPosted: Sun May 27, 2007 5:23 am    Post subject: Thanks Reply with quote

THANKS!!!

You both are GENIUSES! Tosser^^'s code worked best for me.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests 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