Just pointing something out here, "$upper $nick" is wrong, you want "$upper($nick)"

Also, you could have made it a ton easier to make this script if you hadn't hardcoded everything like that.