dialog spamdialog {
  title "Spamfilter Dialog | Ekleme - Silme - Düzenleme | "
  size -1 -1 405 250
  option dbu
  list 1, 10 10 285 132, size extsel hsbar
  box "Görüntüle - Düzenle", 2, 300 7 95 135
  text "Hedef:", 3, 304 28 25 8
  text "Uygulama:", 4, 344 28 30 8
  text "Süre:", 5, 344 50 20 8
  text "Sebep:", 6, 304 72 25 8
  text "Yakalanacak Metin:", 7, 304 94 61 8
  text "Ekleyen:", 8, 304 116 50 8
  edit "", 9, 303 36 35 10, read
  edit "", 10, 343 36 35 10, read
  edit "", 11, 343 58 35 10, read
  edit "", 14, 303 80 85 10, read
  edit "", 13, 303 102 85 10, read
  edit "", 12, 303 124 85 10, read
  check "Düzenle", 15, 353 13 35 10
  combo 17, 343 36 35 50, hide size drop
  combo 18, 343 58 35 50, hide size drop
  check "c", 19, 303 36 10 10, hide push
  check "p", 20, 314 36 10 10, hide push
  check "n", 21, 325 36 10 10, hide push
  check "a", 22, 303 47 10 10, hide push
  check "N", 23, 314 47 10 10, hide push
  check "d", 24, 325 47 10 10, hide push
  check "t", 25, 303 58 10 10, hide push
  check "u", 26, 314 58 10 10, hide push
  check "P", 27, 325 58 10 10, hide push
  button "Sıfırla", 62, 309 119 35 12, hide
  button "Uygula", 28, 353 119 35 12, hide
  box "Yeni Spam Ekle:", 16, 10 163 385 65
  box "Hedef:", 29, 15 172 166 50
  check " c : Kanal Msj.", 30, 20 182 43 10
  check " p : Özel Msj.", 31, 70 182 43 10
  check " a : Away Msj.", 32, 125 182 45 10
  check " n : Özel Notice", 33, 20 194 50 10
  check " N : Kanal Notice", 34, 70 194 50 10
  check " d : DCC", 35, 125 194 35 10
  check " t : Topic", 36, 20 206 30 10
  check " u : nick!user@host:realname", 37, 98 206 80 10
  check " P : Part Msj.", 38, 54 206 40 10
  box "Uygulama:", 61, 185 172 100 50
  radio "Kill", 39, 190 182 28 10, group
  radio "Shun", 40, 190 194 28 10
  radio "Kline", 41, 190 206 28 10
  radio "Gline", 42, 219 182 28 10
  radio "Zline", 43, 219 194 28 10
  radio "Gzline", 44, 219 206 28 10
  radio "Block", 45, 248 182 30 10
  radio "DccBlock", 46, 248 194 32 10
  radio "TempShun", 47, 248 206 34 10
  text "Sebep:", 48, 290 177 19 8
  edit "", 49, 310 176 80 10, autohs
  text "Yakalanacak Metin:", 50, 290 190 52 8
  edit "", 51, 290 198 100 10, autohs
  button "Ekle", 52, 360 211 30 12
  button "Yenile", 53, 70 147 37 12
  button "Tamam", 54, 147 233 35 12, ok
  button "Kapat", 55, 222 233 35 12, cancel
  button "Seçilen(ler)i Sil", 56, 10 147 50 12
  text "Süre:", 57, 290 213 17 8
  combo 58, 310 212 35 50, size drop
  check "Spamfilteri TXT'den Okut:", 59, 311 149 69 10, left
  box "", 60, 300 142 95 21
}


on *:dialog:spamdialog:init:*:{
  didtok $dname 17 44 kill,shun,kline,gline,zline,gzline,block,dccblock,tempshun
  didtok $dname 18,58 44 -,15dk.,30dk.,45dk.,1saat,3saat,5saat,1gün,5gün,10gün
  did -c $dname 58 1
  $iif(%spm_txt,did -c $dname 59)
}
on *:dialog:spamdialog:sclick:59:{ 
  if %spm_txt { unset %spm_txt | did -u $dname 59 } | else { set %spm_txt 1 | filter -if $dname 1 spamlist.txt | did -c $dname 59 }
}
on *:dialog:spamdialog:sclick:15:{
  var %satır = $did(1,$did(1).sel).text 
  did -v $dname 8-12 | did -h $dname 17-28,62 | did -m $dname 13,14 | did -u $dname 19-27
  if $did(15).state == 1 {
    did -h $dname 8-12 | did -v $dname 17-28,62 | did -n $dname 13,14 | did -u $dname 19-27
    did -c $dname 17 $findtok($didtok(17,44),$did(10,$did(10).sel).text,1,44)
    did -c $dname 18 $findtok($didtok(18,44),$did(11,$did(11).sel).text,1,44)
    if c isincs $gettok(%satır,2,32) { did -c $dname 19 }
    if p isincs $gettok(%satır,2,32) { did -c $dname 20 }
    if n isincs $gettok(%satır,2,32) { did -c $dname 21 }
    if a isincs $gettok(%satır,2,32) { did -c $dname 22 }
    if N isincs $gettok(%satır,2,32) { did -c $dname 23 }
    if d isincs $gettok(%satır,2,32) { did -c $dname 24 }
    if t isincs $gettok(%satır,2,32) { did -c $dname 25 }
    if u isincs $gettok(%satır,2,32) { did -c $dname 26 }
    if P isincs $gettok(%satır,2,32) { did -c $dname 27 }
  }
}
on *:dialog:spamdialog:sclick:1:{
  var %satır = $did(1,$did(1).sel).text
  if ($gettok(%satır,1,32) === f) { 
    did -ub $dname 15 | did -v $dname 8-12 | did -h $dname 17-28,62 | did -m $dname 13,14 | did -u $dname 19-27
  }
  if ($gettok(%satır,1,32) === F)  { 
    did -eu $dname 15 | did -v $dname 8-12 | did -h $dname 17-28,62 | did -m $dname 13,14 | did -u $dname 19-27
  }
  if $did(15).state == 1 {
    did -u $dname 19-27
  }
  if ($did(1,0).sel > 1) { did -ub $dname 15 | did -r $dname 9-14 }
  else {
    did -ra $dname 9 $gettok(%satır,2,32)
    did -ra $dname 10 $gettok(%satır,3,32)
    did -ra $dname 11 $süre_spm($gettok(%satır,4,32))
    did -ra $dname 12 $gettok($gettok(%satır,6,32),1,33)
    did -ra $dname 13 $gettok(%satır,7-,32)
    did -ra $dname 14 $gettok(%satır,5,32)
  }
}
on *:dialog:spamdialog:sclick:62:{
  var %satır = $did(1,$did(1).sel).text 
  did -u $dname 19-27
  did -c $dname 17 $findtok($didtok(17,44),$did(10,$did(10).sel).text,1,44)
  did -c $dname 18 $findtok($didtok(18,44),$did(11,$did(11).sel).text,1,44)
  did -ra $dname 13 $gettok(%satır,7-,32)
  did -ra $dname 14 $gettok(%satır,5,32)
  if c isincs $gettok(%satır,2,32) { did -c $dname 19 }
  if p isincs $gettok(%satır,2,32) { did -c $dname 20 }
  if n isincs $gettok(%satır,2,32) { did -c $dname 21 }
  if a isincs $gettok(%satır,2,32) { did -c $dname 22 }
  if N isincs $gettok(%satır,2,32) { did -c $dname 23 }
  if d isincs $gettok(%satır,2,32) { did -c $dname 24 }
  if t isincs $gettok(%satır,2,32) { did -c $dname 25 }
  if u isincs $gettok(%satır,2,32) { did -c $dname 26 }
  if P isincs $gettok(%satır,2,32) { did -c $dname 27 }
}
on *:dialog:spamdialog:sclick:28:{
  var %satır = $did(1,$did(1).sel).text 
  var %y = 19 { while %y <= 27 { if $did(%y).state == 1 { set -u5 %hedef $addtokcs(%hedef,$did(%y),44) } | inc %y } }
  spamfilter del $gettok(%satır,2,32) $gettok(%satır,3,32) $gettok(%satır,4,32) $gettok(%satır,5,32) $gettok(%satır,7-,32)
  spamfilter add $remove(%hedef,$chr(44)) $did(17,$did(17).sel).text $saniye($did(18,$did(18).sel).text) $&
    $iif(!$did(14),-,$replace($did(14),$chr(32),$chr(95))) $did(13)
  noop $input(Spamfilter belirttiğiniz şekilde düzenlendi.,o)
  if %spm_txt {
    write $+(-l,$did(1).sel) spamlist.txt F $remove(%hedef,$chr(44)) $did(17,$did(17).sel).text $&
      $saniye($did(18,$did(18).sel).text) $iif(!$did(14),-,$replace($did(14),$chr(32),$chr(95))) $&
      $address($me,5) $did(13)
  loadbuf -ro $dname 1 spamlist.txt } | else { did -r $dname 1 | stats f }
}
on *:dialog:spamdialog:sclick:56:{
  if $did(1,0).sel == 1 {
    if $left($did(1).seltext,1) === f { noop $input(Bu spamfilter silinemez!,ohud,Hata!) | goto son }
    spamfilter del $gettok($did(1).seltext,2-5,32) $gettok($did(1).seltext,7-,32)
    $iif(%spm_txt,write $+(-d,$did(1).sel) spamlist.txt)
  }
  else {
    var %a = 1
    while %a <= $did(1,0).sel {
      $iif($left($did(1,$did(1,%a).sel).text,1) === f, inc %h)
      spamfilter del $gettok($did(1,$did(1,%a).sel).text,2-5,32) $gettok($did(1,$did(1,%a).sel).text,7-,32)
      $iif(%spm_txt,write $+(-d,$did(1).sel) spamlist.txt)
      inc %a
    }
  }
  noop $input(Seçtiğiniz $qt($did(1,0).sel) spamfilter girdisinden $qt($calc($did(1,0).sel - %h)) tanesi silindi.,o)
  unset %h | did -r $dname 1 | $iif(%spm_txt,loadbuf -o $dname 1 spamlist.txt,stats f)
  :son
}
on *:dialog:spamdialog:sclick:53:{ did -r $dname 1 | $iif(%spm_txt,loadbuf -o $dname 1 spamlist.txt,stats f) }
on *:dialog:spamdialog:sclick:52:{ 
  var %y = 30 { while %y <= 38 { if $did(%y).state == 1 { set -u5 %hedef $addtokcs(%hedef,$mid($did(%y),2,2),44) } | inc %y } }
  var %z = 39 { while %z <= 47 { if $did(%z).state == 1 { set -u5 %uygulama $lower($did(%z)) } | inc %z } }
  if (!%hedef || !%uygulama) { noop $input(Yeni spamfilter için hedef ya da uygulama seçmediniz!,ohud,Hata!) }
  else {
    spamfilter add $remove(%hedef,$chr(44)) %uygulama $saniye($did(58,$did(58).sel).text) $&
      $iif(!$did(49),-,$replace($did(49),$chr(32),$chr(95))) $did(51)
    $iif(%spm_txt,write spamlist.txt F $remove(%hedef,$chr(44)) %uygulama $saniye($did(58,$did(58).sel).text) $&
      $iif(!$did(49),-,$replace($did(49),$chr(32),$chr(95))) $address($me,5) $did(51))
    noop $input(Belirttiğiniz spamfilter eklendi.,o)
    did -r $dname 1,49,51
    did -u $dname 30-47
    did -c $dname 58 1
    $iif(%spm_txt,loadbuf -o $dname 1 spamlist.txt,stats f)
  }
}
alias süre_spm { return $replace($duration($1),secs,saniye,sec,saniye,mins,dk.,hrs,saat,days,gün,day,gün,wk,hafta,min,dk.,Hr,saat) }
alias saniye { 
  if gün isin $1- { return $calc($remove($1-,gün) * 86400) }
  if dk. isin $1- { return $calc($remove($1-,dk.) * 60) }
  if saat isin $1- { return $calc($remove($1-,saat) * 3600) }
  else { return - }
}
menu status,query,channel { 
  $iif(o !isincs $usermode,$style(2)) Spamfilter Dialog:spamdialog
}
alias -l spamdialog { dialog $iif($dialog(spamdialog),-v,-m spamdialog) spamdialog | stats f }
raw 229:*:{ if $dialog(spamdialog) { tokenize 32 $1- | did -az spamdialog 1 $2-4 $7- | halt } }
raw 219:*:{ if $2 === f && $dialog(spamdialog) { $iif(%spm_txt,filter -if spamdialog 1 spamlist.txt) | halt } }
