Code:
on *:start:{
  if !$hget(BadWords) { .hmake BadWords 10 }
  if $exists(BadWords.hsh) { .hload BadWords BadWords.hsh }
}
on *:exit:{
  .hsave -o BadWords BadWords.hsh
}
on *:disconnect:{
  .hsave -o BadWords BadWords.hsh
}

menu menubar {
  -
  Private Offensive Message
  .Turn $iif($hget(BadWords,0),Off,On) : .hadd -m BadWords 0 $iif($hget(BadWords,0),$false,$true)
  .-
  .Add a word : .hadd -m BadWords $$?="Bad Word to be added" $true
  .-
  .Remove a word : .hdel BadWords $$?="Bad Word to be removed"
  .-
  .List Spam Words : .bad_words_list
  .-
}
alias -l bad_words_list {
  var %a = 1, %b = $hget(BadWords,0).item
  unset %badwords
  while %a <= %b {
    set %badwords $addtok(%badwords,$hget(BadWords,%a).item,32)
    if ($calc($numtok(%badwords,32) + $len(%badwords)) > 900) {
      echo -a $replace(%badwords,$chr(32),$+($chr(44),$chr(32)))
      unset %badwords
    }
    inc %a
  }
  if %badwords {
    echo -a $replace(%badwords,$chr(32),$+($chr(44),$chr(32)))
    unset %badwords
  }
}
on *:open:?:{
  if ($ulevel != op) && ($hget(BadWords,0)) {
    var %cnt = 1
    while (%cnt <= $hget(BadWords,0).item) {
      if ($hget(BadWords,%cnt).item isin $1-) {
        close -m $nick
        .timer. $+ $nick 1 1 spamdetect
        halt
      }
      inc %cnt
    }
  }
}
on ^*:notice:*:?: {
  var %oknames = ChanServ NickServ MemoServ
  if ($nick !isin %oknames) && ($hget(BadWords,0)) {
    var %cnt = 1
    while (%cnt <= $hget(BadWords,0).item) {
      if ($hget(BadWords,%cnt).item isin $1-) {
        .timer. $+ $nick 1 1 spamdetect
        halt
      }
      inc %cnt
    }
  }
}
alias spamdetect {
  var %i = 1
  if $comchan($nick,0) {
    while $comchan($nick,%i) {
      var %c = $v1
      if $me isop %c && $nick isreg %c { ban -ku600 %c $nick 2  14Private Offensive Language  }
      inc %i
    }
  }
}


learn learn learn