As you can see in the Xchat::hook_print command, the subroutine cw_notice will be executed when a notice is sent to you. You can find these events like Notice, Channel Message, Channel Action etc in the Settings -> Advanced -> Text Events... menu in XChat.

The cw_notice subroutine will set the context to your current window and will echo in it the nick and the notice received.