alias convert {

  set %buf1 $replace($lower($remove($1,$chr(44),!,_,.,-,/,\,*,^,+,?,",`)),А,а,Б,б,В,в,Г,г,Д,д,Е,е,Ё,ё,Ж,ж,З,з,И,и,К,к,Л,л,М,м,Н,н,О,о,П,п,Р,р,С,с,Т,т,У,у,Ф,ф,Х,х,Ц,ц,Ч,ч,Ш,ш,Щ,щ,Ь,ь,Ы,ы,Ъ,ъ,Э,э,Ю,ю,Я,я)
  set %buf1 $replace(%buf1,а,a,е,e,д,g,и,u,к,k,м,m,о,o,п,n,р,p,с,c,у,y,х,x,ч,4,з,3,ь,b)

  ;remove repeats

  set %buf2 1
  :loop
  if ($mid(%buf1,%buf2,1) ==  $mid(%buf1,$calc(%buf2 + 1),1)) {
    if (%buf2 > 1) set %buf1 $add($mid(%buf1,1,$calc(%buf2 - 1)),$mid(%buf1,$calc(%buf2 + 1),$len(%buf1)))
    else set %buf1 $mid(%buf1,2,$len(%buf1))
    dec %buf2
  }
  inc %buf2
  if (%buf2 < $len(%buf1)) goto loop
  return %buf1
}

alias html2 {
  .remove %proffile
  write %proffile <head><title>IRC Profanity Statistics</title></head>
  write %proffile <body bgcolor=white><font size=7><center>Profanity Rating</center></font>
  write %proffile <center>This file was generated by Filter Bot (, <a href="http://defect.by.ru">http://defect.by.ru</a>)<br>
  write %proffile Last updated: $fulldate <br><br>
  write %proffile <table border="1" width="500">

  set %buf3 $calc($lines(SYSTEM\Scripts\No_Mat\filter.log) + 1)
  set %buf2 1
  :next
  set %buf1 $read -l %buf2 SYSTEM\Scripts\No_Mat\filter.log
  write %proffile <tr><td> $left(%buf1,$pos(%buf1,$chr(32),1)) </td><td> $right(%buf1,$calc(0 - $pos(%buf1,$chr(32),1)))
  inc %buf2
  if (%buf2 < %buf3) goto next

}

alias filter {
  if (($convert($1) == $read -w $convert($1) SYSTEM\Scripts\No_Mat\!DICT.TXT) && ($convert($1) != $null)) goto next 
  if (($convert($2) == $read -w $convert($2) SYSTEM\Scripts\No_Mat\!DICT.TXT) && ($convert($2) != $null)) goto next 
  if (($convert($3) == $read -w $convert($3) SYSTEM\Scripts\No_Mat\!DICT.TXT) && ($convert($3) != $null)) goto next 
  if (($convert($4) == $read -w $convert($4) SYSTEM\Scripts\No_Mat\!DICT.TXT) && ($convert($4) != $null)) goto next
  if (($convert($5) == $read -w $convert($5) SYSTEM\Scripts\No_Mat\!DICT.TXT) && ($convert($5) != $null)) goto next
  if (($convert($6) == $read -w $convert($6) SYSTEM\Scripts\No_Mat\!DICT.TXT) && ($convert($6) != $null)) goto next
  if (($convert($7) == $read -w $convert($7) SYSTEM\Scripts\No_Mat\!DICT.TXT) && ($convert($7) != $null)) goto next
  if (($convert($8) == $read -w $convert($8) SYSTEM\Scripts\No_Mat\!DICT.TXT) && ($convert($8) != $null)) goto next
  if (($convert($9) == $read -w $convert($9) SYSTEM\Scripts\No_Mat\!DICT.TXT) && ($convert($9) != $null)) goto next

  halt
  :next

  if ($exists(SYSTEM\Scripts\No_Mat\!EXCL.TXT) != $false) {
    set %buf1 $lines(SYSTEM\Scripts\No_Mat\!EXCL.TXT)
    ; Файл исключение! тут хранятся ники которые ни когда не попадут в статистику
    :loop
    set %buf2 $read -l %buf1 SYSTEM\Scripts\No_Mat\!EXCL.TXT
    if ($nick isin %buf2) halt
    dec %buf1
    if (%buf1 > 0) goto loop
  }
  if (%aban == on) ban # $nick 2
  else ban # $nick 2
  kick # $nick 2,211«4|9Забанен4|11» 4по причине: 05[2,29Маты с оскорблениями на канале 4ЗАПРЕЩЕНЫ!05]4:
  inc %kick
  if ($exists(SYSTEM\Scripts\No_Mat\filter.log) == $false) write SYSTEM\Scripts\No_Mat\filter.log $nick 0
  set %buf4 $read -s $nick SYSTEM\Scripts\No_Mat\filter.log
  inc %buf4

  set %buf5 $calc($lines(SYSTEM\Scripts\No_Mat\filter.log) + 1)
  set %buf1 1
  :nxt
  set %buf2 $read -l %buf1 SYSTEM\Scripts\No_Mat\filter.log
  set %buf3 $right(%buf2,$calc(0 - $pos(%buf2,$chr(32),1)))
  if (%buf4 => %buf3) {
    write -ds $nick SYSTEM\Scripts\No_Mat\filter.log
    write -il %buf1 SYSTEM\Scripts\No_Mat\filter.log $nick %buf4
    goto skipw
  }
  inc %buf1
  if (%buf1 < %buf5) goto nxt
  write -s $nick SYSTEM\Scripts\No_Mat\filter.log $nick %buf4

  :skipw


}

on 1:TEXT:*:#:{ filter $$1- }
on 1:ACTION:*:#:{ filter $$1- }
on 1:NOTICE:*:#:{ filter $$1- }
on 1:CTCP:*:#:{ filter $$1- }