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.

TCL script question

Old posts that have not been replied to for several years.
Locked
R
Rampage

Post by Rampage »

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
}
}
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Trimming the text is not sufficient, as it leaves staces in the text, and if you add a space to the chars it trims off, you end up with a blank string.

The proper way to get the channel key would be somthing simalar.
pushmode chan -k [lindex [getchanmode $chan] 1]
Locked