on *:QUIT: {
if (*spam spam* iswm $1-) {
;do stuff here
}
}
This will perform the commands you put in the 'do stuff here' section if the quit msg matches against the *spam spam*. Obviously edit the *spam spam* to suit your needs, and add your desires code under the ';do stuff here' line.
I dont see why you would want to ban somebody on quit, since they have already left. In the case of some sort of join/part/quit flood, no custom quit message will be seen as most servers refuse to display a custom quit message unless the user has been connected for a certain amount of time. Also, the $chan identifier can not be used in an on quit event, because quits are a network thing and in no way related specifically to any channel.