Xchat::register ("CWN", "0.1.0", "Displays notices in current window");
Xchat::hook_print ("Notice", cw_notice, "");
Xchat::command ("ECHO Received a notice from $_: $_");
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.