below is the code to my script. what i would like is to .rkey #chan and have it remove the current key if there is on, and then set a random key. if a key isn't set then just set a random key. the problem is it sorta works now. it just doesn't unset the old key and make a new one.
bind dcc o|n rkey dcc:rkey
proc isnum { number } {
return [regexp ^(-|[0-9]*)[0-9]+$ $number]
}
proc randkey { length } {
if {![isnum $length]} { return "" }
set string ""
for {set i 0} {$i < $length} {incr i} {
set rand [rand 64]
append string [string range "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" $rand $rand]
}
return $string
}
proc dcc:rkey {hand xid chan} {
putcmdlog "#$hand# rkey $chan"
if {$chan == ""} {
putdcc $xid "Usage: rkey <channel>"
return 0
}
if {![string match $chan [string tolower [channels]]]} {
putdcc $xid "Error: I'm not on $chan"
return 0
}
if {![botisop $chan]} {
putdcc $xid "I'm not oped on $chan"
return 0
}
if {[string match *k* [getchanmode $chan]]} {
putdcc $xid "|[string trimright [string trimleft [getchanmode $chan] +ipsmtnkl] 123456789]|"
putdcc $xid "attempting to unset +k"
pushmode $chan -k [string trimright [string trimleft [getchanmode $chan] +ipsmtnkl] 123456789]]
putdcc $xid "attempting to set +k"
pushmode $chan +k [randkey 8]
return 0
}
if {![string match *k* [getchanmode $chan]]} {
pushmode $chan +k [randkey 8]
return 0
}
}