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.

Replacing flags with access level

Old posts that have not been replied to for several years.
Locked
S
Stafford

Post by Stafford »

Hi, I've got this here. Instead of .chattr $handle +flags, is there anyway I can set a system of access level such that it ranges from 10 to 50? Example, if access level 10 is given, it can be used to perform certain specific commands (ie: like some msg commands written in TCL)

Thanks

<font size=-1>[ This Message was edited by: Stafford on 2001-12-31 09:24 ]</font>
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Sure, write a tcl that gives everyone the same flags and uses setuser xtra to store an access level. Then rebind all the commands to check for the proper access level.
S
Stafford

Post by Stafford »

Hmm, could you show me an example of the code?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Examples do not come small, especialy in this situation.

As stated, each time a command is tytped, you would have to use a script to check the access level of a user, check if that command is available to that access level.

It would be more sensible to learn how to use eggdrops flag system.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Here's a quick example. I didn't test it, so it might not work, but maybe it will give you an idea of how I would do it. Note, if you .rehash your bot after this script is loaded, everything will break.

Do ".level someuser" to see that person's level, or ".level someuser 75" to change that person's level (to 75).

Code: Select all

# the initial person to give level 100 to
set super_user stdragon

# put the names of dcc commands here
# and set the required level for it
set dcc_levels(voice) 5
set dcc_levels(devoice) 5
set dcc_levels(op) 10
set dcc_levels(deop) 10

# beginning of code
setuser $super_user XTRA level 100
foreach cmd [array names $dcc_levels] {
  set old [bind dcc - $cmd]
  set old_procs($cmd) $old
  bind dcc - $cmd [list dcc_check $cmd]
}

proc dcc_check {cmd hand idx text} {
  global dcc_levels old_procs
  set level [getuser $hand XTRA level]
  if {$level < $dcc_levels($cmd)} {
    putdcc $idx "Sorry, your level ($level) is too low to use this command ($dcc_levels($cmd))"
    return 0
  }
  set flags [chattr $hand]
  chattr $hand +n
  set retval [$old_procs($cmd) $hand $idx $text]
  chattr $hand -abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
  chattr $hand +$flags
  return $retval
}

bind dcc - level dcc_level
proc dcc_level {hand idx text} {
  set level [getuser $hand XTRA level]
  if {$level < 100} {return 0}
  set parts [split $text]
  set user [lindex $parts 0]
  if {[llength $parts] > 1} {
    set level [lindex $parts 1]
    setuser $user XTRA level $level
  } else {
    set level [getuser $user XTRA level]
    putdcc "$user's level is $level"
  }
  return 0
}
<font size=-1>[ This Message was edited by: stdragon on 2002-01-01 23:21 ]</font>
S
Stafford

Post by Stafford »

On 2002-01-01 23:15, stdragon wrote:
Note, if you .rehash your bot after this script is loaded, everything will break.
What does that means? Does it means that if I .rehash, everything I've set would be lost? In that case, is there anyway such that let's make it more fancy. Let's take it such that $handle and access level are being written to a file. The file works just like userfile and channel file. It will save all details of the $handle, individual access in different channels etc. Any ideas?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

On 2002-01-02 21:38, Stafford wrote:
On 2002-01-01 23:15, stdragon wrote:
Note, if you .rehash your bot after this script is loaded, everything will break.
What does that means? Does it means that if I .rehash, everything I've set would be lost? In that case, is there anyway such
It means that if you rehash, the commands will stop working.
that let's make it more fancy. Let's take it such that $handle and access level are being written to a file. The file works just like userfile and channel file. It will save all details of the $handle, individual access in different channels etc. Any ideas?
Yes, here's an idea.. you asked for example code and I gave you some. I don't really want to do all the work for you!
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Wouldn't it be better to be working with the FILT bind anyway.
S
Stafford

Post by Stafford »

Yes, here's an idea.. you asked for example code and I gave you some. I don't really want to do all the work for you!
hehe, Ok, don't take it too hard. Sometimes, humans just ask a little too much :smile: No hard feelings. Thanks for the sample code anyway.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

On 2002-01-02 22:13, ppslim wrote:
Wouldn't it be better to be working with the FILT bind anyway.
If it were only for dcc commands, then maybe yes, but he said msg commands, too, so I used a more general approach. You just need to write a msg_check function and copy the re-bind code, basically. Same for public commands.

Another problem with FILT is that since the dcc bind table checks for partial commands (i.e. ".+ch" matches ".+chan") you would have to do some fancy matching to catch them all.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

On 2002-01-02 22:14, Stafford wrote:

Yes, here's an idea.. you asked for example code and I gave you some. I don't really want to do all the work for you!


hehe, Ok, don't take it too hard. Sometimes, humans just ask a little too much :) No hard feelings. Thanks for the sample code anyway.
I'm sorry, I wasn't trying to sound mad or anything, more like funny. I guess my sense of humor isn't the greatest ;)

Err.. on the previous topic though, there really isn't that much work left for you to do, if you are interested in pursuing this script.

Add a check to see if the script is already loaded on .rehash, so that it won't re-bind twice and destroy everything.

Code: Select all

if {![info exists levels_loaded]} {
  set levels_loaded yup
  foreach ... blah blah.. all the non-config, non-proc code goes here
}
Then, you basically copy all the dcc stuff and change "dcc" to "msg" for message commands (and change the args to msg_check). And "pub" for public commands.. etc. All the hard work is already done :)

Oh and you would have to add a check in the other procs to see if the person is a valid user or not. Maybe a "default_level" variable would be good to add, so that if the level isn't found, that is what gets used.

And finally.. I forget if this is already in there or not.. but there should be "catch {}" around the $old_proc call, so that if there's a tcl error, the user doesn't keep the +n flag.

And finallly, since "owner" is a read-only variable, there will be some things that you just cannot do with this level checking script. You can't give someone temporary perm-owner status, except maybe by doing some tricky host manipulation stuff, but I don't think that would work, because it wouldn't take effect until the next time the command is used.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

By the way, let me know if the script actually works, heh. I still haven't tested it.
Locked