I recommend the use of $strip so when a person types @ with control codes, it will get triggered too:
on *:text:*:#: { $iif($strip($1) == @,$iif($nick isop #,.msg # 4 OPERATOR ( $nick ): $2-,$iif($nick isvoice #,.msg # 9 MODERATOR ( $nick ): $2-))) }
The code I provide here works exactly the same.