Don't know why you want this, I mean, if you don't want to join the channel, just don't double click it. However, this is what I came up with, and it worked in my trials
alias whois {
.enable #no.connect.whois
!.whois $1
}
#no.connect.whois off
raw 319:*:{
echo -s $remove($1-,$chr(35))
haltdef
}
raw 318:*:{
.disable #no.connect.whois
}
#no.connect.whois end