Some networks have modes which help counter spam. For example, DALnet has +R which only allows registered users to speak to you, EFnet has +g which blocks all PMs until you accept them. You will need to ask in your network's #Help channel if such modes exist.
However, mIRC script can also be used (which I guess is why you've posted here!), here is an example of one way:
on ^*:open:?:*:{
if (*porn* iswm $1-) || (*XXX* iswm $1-) {
.msg $nick Spam has been detected, your message has been blocked.
.ignore -pn $nick 3
halt
}
}This will block all messages from users who's first message to you contains the word "porn" OR contains "XXX". It will also message them with that sentence, and ignore all future private messages and notices from their address. It also will stop the query window from opening at all, so you won't even know you've been messaged
For further information see
/help ON OPEN.
Regards,