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
}
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?On 2002-01-01 23:15, stdragon wrote:
Note, if you .rehash your bot after this script is loaded, everything will break.
It means that if you rehash, the commands will stop working.On 2002-01-02 21:38, Stafford wrote:What does that means? Does it means that if I .rehash, everything I've set would be lost? In that case, is there anyway suchOn 2002-01-01 23:15, stdragon wrote:
Note, if you .rehash your bot after this script is loaded, everything will break.
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!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?
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.On 2002-01-02 22:13, ppslim wrote:
Wouldn't it be better to be working with the FILT bind 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 greatestOn 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.
Code: Select all
if {![info exists levels_loaded]} {
set levels_loaded yup
foreach ... blah blah.. all the non-config, non-proc code goes here
}