Not a bad method and I agree about the variables being an issue. I might suggest using a hash table for that.

Also, you want to change the on TEXT event to not use #, but to use ? instead. On join spam is PM or NOTICE and not in the channel itself or else it would be easily noticed.