Your join event is questionable. The $3 shouldn't be the nick who invites the client that runs the code. It should have been $v1 or $nick, meaning the "bot." Your script will only respond to the nickname bot and no one else. My approach will be this:
on $*:TEXT:/( |^)(join \x23(?!\x23)(\S+))/iS:?: {
if ($nick == BotNick) {
$regml(2)
msg $gettok($regml(2),2,32) I was invited by $v1 - I am $me - $iif($3,$3-,Default Message Here)
}
}
This will ensure that it is a channel name starting with a single # prefix and not something else. You can then use an $iif() to ouput the message, which is $3-; if not provided, it returns Default Message here.