You can use $target to check to whom the notice was sent.
For op notice check the presence of @ in $target
For chan notice check for #
Some networks allow voice notices as well in which case you would look for +
And as with other events you can prefix the event with ^ and halt the default output.
I did not understand your help.
You can explain to me how I'm going to use the $ target in the code.