The code works correctly according to the description and examples provided in the first post of your request.
The description did not mention that in addition to the nick, it was also planned to use a full mask with the host/IP address.

Ok, I made a few additional changes to the code. Try using this:
Code
alias addnick {
  if ($1) {
    if ($numtok($1,64) == 2) { echo -ag Return 1: $1 }
    else {
      var %nick $remove($1,*,!,@), %chars $remove($1,%nick)
      if ($left(%chars,1) == *) { echo -ag Return 2: $+(%nick,*!*@*) }
      elseif ($left(%chars,1) == !) { echo -ag Return 3: $+(%nick,!*@*) }
      else { echo -ag Return 4: $1 }
    }
  }
}


Note: This code probably won't be able to cover and correctly recognize all possible input data variants, so I would recommend splitting the functionality into several aliases, creating several commands: /addnick and /addhost. In the first case, the mask check will be performed based on the nick, and in the second case, based on the host/IP address.


🌐 https://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples