To know the number of any raw reply, simply type
/debug -p @window (-p is for wrapping long lines).
Here's a script that captures the channels information:
raw 319:*:echo -> $2 is on: $3- | halt
As for a protection script, check out
this page, and make sure to read the "reaction levels" part too.