Here's my shot.

Code:
on @*:text:*:#: {
  ;Next command line skips the "bad word" test if the message was sent by a channel operator.
  ;But why would you allow channel operators swear if anyone else can't?
  if ($nick isop $chan) goto ops_can_swear
  var %i = $numtok(%bad_word_list,32)
  var %address = $address($nick,[color:green]3[/color])
  while (%i) {
    if ($istok($1-,$gettok(%bad_word_list,%i,32),32)) {
      inc %bad_word_counter_ [ $+ [ $chan ] $+ ] _ [ $+ [ %address ] ]
      if (%bad_word_counter_ [ $+ [ $chan ] $+ ] _ [ $+ [ %address ] ] == 1) {
        notice $nick Swearing is not allowed on $chan $+ .
        break
      }
      if (%bad_word_counter_ [ $+ [ $chan ] $+ ] _ [ $+ [ %address ] ] == 2) {
        notice $nick I have said already, swearing IS NOT allowed on $chan $+ !
        notice $nick For now you have been silenced for 15 minutes.
        notice $nick Next time you'll be kicked and banned from $chan $+ .
        mode $chan -v $nick
        ban -u[color:blue]900[/color] $chan $nick [color:green]3[/color]
        break
      }
      if (%bad_word_counter_ [ $+ [ $chan ] $+ ] _ [ $+ [ %address ] ] >= 3) {
        ban -u[color:red]36000[/color] $chan $nick [color:green]3[/color]
        .timer 1 3 kick $chan $nick Ok, still swearing. You're going out!
        %bad_word_counter_ [ $+ [ $chan ] $+ ] _ [ $+ [ %address ] ] = 1
        break
      }
    }
    dec %i
  }
  :ops_can_swear ;Which is unfair, don't you think?
}


Remember to set bad word variable:
/set %bad_word_list badword1 badword2 badword3 [and so on]

The logic of the script is this:
1) First message containing a "bad word": User gets warning notice.
2) Second message containing a "bad word": User gets warning and is banned (but not kicked) for 15 minutes (900 seconds). This means user can stay on the #channel but can't send any messages within 15 minutes time. If user decides to leave, he/she can't rejoin within 15 minutes. User is also devoiced (-v) because the possible voice mode (+v) overrides ban.
3) Third message containing a "bad word": User gets banned from #channel for 10 hours (36000 seconds). If the same user comes in after that 10 hour period and uses "bad words" again, he/she gets silenced for 15 minutes right away (no first warning).

This script is channel-specific, so user may get banned from one channel you have ops but can still speak on another (until gets banned from there too smile ). In "bad word counter" I used user's address in form
"*!*user@*.address.net". This means user can even change his/her nick without counter being fooled. You can change the address mask by changing the green numbers up there in the script to something between 0-19 (/help $mask for more info).

I know that similar auto-ban&kick-from-swearing scripts have been posted many times before. This is just how I would like to do this.

Last edited by Derethil; 11/04/04 06:47 AM.