I'm not new to eggdrop's but i am fairly new to scripting. I have written about 10 scripts for my personal use mainly !trigger related scripts and i am trying to write a script to retrive the key from a channel i specify that the bot is in.

I have gotten so far but the bot seems to retrieve the number of people in the channel rather than the key that is set.

All i need is the line that retrieves the channel key if any of you could possibly help me.
Here is the proc i have written to retrieve the key
proc currentkey {chan} {
set currentmodes [getchanmode $chan]
if {[string match "*k*" [lindex $currentmodes 0 ]]} {
return [lindex $currentmodes end]
}
return 0
}
please try not to laugh at my code too much

Thanks in advance. Jon.
