dialog autom {
  title "Auto-Msg"
  size -1 -1 483 368
  option pixels
  box "Choix du message", 1, 14 11 127 264
  radio "Quand tu arrive", 2, 23 25 109 25, group push
  radio "Quand on te OP", 4, 23 60 109 25, push
  radio "Quand on te Deop", 5, 23 90 109 25, push
  radio "Quand on te Devoice", 6, 23 165 109 25, push
  radio "Quand on te Voice", 7, 23 134 109 25, push
  radio "Quand on te Ban", 8, 23 209 109 25, push
  radio "Quand on te Kick", 9, 23 240 109 25, push
  box "Configuration", 10, 4 -2 476 366
  list 11, 13 279 461 54, size
  button "Ajouter", 12, 238 247 75 25
  button "Retirer", 13, 316 247 75 25
  check "Activer", 14, 150 248 57 20
  radio "Msg sur le salon", 15, 150 98 100 20, group
  radio "Notice", 16, 150 173 57 20
  radio "En privé", 17, 150 33 100 20
  radio "Normal", 23, 150 98 80 20
  radio "Anti-PV", 24, 150 173 80 20
  button "QUITTER", 19, 395 247 75 25, flat ok
  text "Aperçu", 21, 12 341 47 16
  edit "", 22, 62 338 412 22
  box "", 3, 18 49 119 70
  box "", 18, 18 124 119 70
  box "", 25, 18 199 119 70
  icon 26, 311 9 162 146
}


on *:dialog:autom:init:0:{
  did -c autom 2
  filter -fo TXT\join.txt autom 11
  did -b autom 16,17
  did -h autom 23,24
  if %autom.sjoin == 1 { did -c autom 14 | did -e autom 15 }
  if %autom.sjoin == 0 { did -u autom 14 | did -b autom 15 }
  if %autom.mjoin != $null { did -c autom %autom.mjoin }
}
on *:dialog:autom:sclick:*:{
  if $did == 2 {
    did -h autom 23,24
    did -v autom 15,16,17
    did -i autom 22 1 text +m $crlf
    did -u autom 15,16,17
    did -r autom 11
    filter -fo TXT\join.txt autom 11
    did -b autom 16,17
    if %autom.sjoin == 1 { did -c autom 14 | did -e autom 15,16,17 }
    if %autom.sjoin == 0 { did -u autom 14 | did -b autom 15,16,17 }
    if %autom.mjoin != $null { did -c autom %autom.mjoin }
  }
  if $did == 3 {
    did -v autom 23,24
    did -h autom 15,16,17
    did -i autom 22 1 text +m $crlf
    did -u autom 23,24
    did -r autom 11
    filter -fo TXT\repon.txt autom 11
    if %autom.srepon == 1 { did -c autom 14 | did -e autom 23,24 }
    if %autom.srepon == 0 { did -u autom 14 | did -b autom 23,24 }
    if %autom.mrepon != $null { did -c autom %autom.mrepon }
  }
  if $did == 4 {
    did -h autom 23,24
    did -v autom 15,16,17
    did -i autom 22 1 text +m $crlf
    did -u autom 15,16,17
    did -r autom 11
    filter -fo TXT\op.txt autom 11
    did -e autom 15,16,17
    if %autom.sop == 1 { did -c autom 14 | did -e autom 15,16,17 }
    if %autom.sop == 0 { did -u autom 14 | did -b autom 15,16,17 }
    if %autom.mop != $null { did -c autom %autom.mop }
  }
  if $did == 5 {
    did -h autom 23,24
    did -v autom 15,16,17
    did -i autom 22 1 text +m $crlf
    did -u autom 15,16,17
    did -r autom 11
    filter -fo TXT\deop.txt autom 11
    did -e autom 15,16,17
    if %autom.sdeop == 1 { did -c autom 14 | did -e autom 15,16,17 }
    if %autom.sdeop == 0 { did -u autom 14 | did -b autom 15,16,17 }
    if %autom.mdeop != $null { did -c autom %autom.mdeop }
  }
  if $did == 7 {
    did -h autom 23,24
    did -v autom 15,16,17
    did -i autom 22 1 text +m $crlf
    did -u autom 15,16,17
    did -r autom 11
    filter -fo TXT\voice.txt autom 11
    did -e autom 15,16,17
    if %autom.svoice == 1 { did -c autom 14 | did -e autom 15,16,17 }
    if %autom.svoice == 0 { did -u autom 14 | did -b autom 15,16,17 }
    if %autom.mvoice != $null { did -c autom %autom.mvoice }
  }
  if $did == 6 {
    did -h autom 23,24
    did -v autom 15,16,17
    did -i autom 22 1 text +m $crlf
    did -u autom 15,16,17
    did -r autom 11
    filter -fo TXT\devoice.txt autom 11
    did -e autom 15,16,17
    if %autom.sdevoice == 1 { did -c autom 14 | did -e autom 15,16,17 }
    if %autom.sdevoice == 0 { did -u autom 14 | did -b autom 15,16,17 }
    if %autom.mdevoice != $null { did -c autom %autom.mdevoice }
  }
  if $did == 9 {
    did -h autom 23,24
    did -v autom 15,16,17
    did -i autom 22 1 text +m $crlf
    did -u autom 15,16,17
    did -r autom 11
    filter -fo TXT\kick.txt autom 11
    did -b autom 15
    did -e autom 16,17
    if %autom.skick == 1 { did -c autom 14 | did -e autom 16,17 }
    if %autom.skick == 0 { did -u autom 14 | did -b autom 16,17 }
    if %autom.mkick != $null { did -c autom %autom.mkick }
  }
  if $did == 8 {
    did -h autom 23,24
    did -v autom 15,16,17
    did -i autom 22 1 text +m $crlf
    did -u autom 15,16,17
    did -r autom 11
    filter -fo TXT\ban.txt autom 11
    did -e autom 15,16,17
    if %autom.sban == 1 { did -c autom 14 | did -e autom 15,16,17 }
    if %autom.sban == 0 { did -u autom 14 | did -b autom 15,16,17 }
    if %autom.mban != $null { did -c autom %autom.mban }
  }
  if $did == 11 { if $did(11).sel { did -i autom 22 1 text +m $did(11).seltext } }
  if $did(2).state == 1 {
    if $did == 12 { var %text = $$?="Entre un nouveau texte" | write TXT\join.txt %text | did -a autom 11 %text }
    if $did == 13 { if $did(11).sel { var %text = $did(11).seltext | var %m = $read -s [ $+ [ %text ] ] TXT\join.txt | var %l = $readn | write -dl $+ %l  TXT\join.txt | did -d autom 11 $did(11).sel | did -i autom 22 1 text +m $crlf } | Else { var %errff = $input(Aucune sélection,100,Information) } }
    if $did == 14 {
      if $did(14).state == 1 { did -e autom 15 }
      if $did(14).state == 0 { did -b autom 15 }
      set %autom.sjoin $did(14).state 
    }
    if $did == 15 { set %autom.mjoin 15 }
    if $did == 16 { set %autom.mjoin 16 }
    if $did == 17 { set %autom.mjoin 17 }
  }
  if $did(3).state == 1 {
    if $did == 12 { var %text = $$?="Entre un nouveau texte" | write TXT\repon.txt %text | did -a autom 11 %text }
    if $did == 13 { if $did(11).sel { var %text = $did(11).seltext | var %m = $read -s [ $+ [ %text ] ] TXT\repon.txt | var %l = $readn | write -dl $+ %l  TXT\repon.txt | did -d autom 11 $did(11).sel | did -i autom 22 1 text +m $crlf } | Else { var %errff = $input(Aucune sélection,100,Information) } }
    if $did == 14 {
      if $did(14).state == 1 { did -e autom 23,24 }
      if $did(14).state == 0 { did -b autom 23,24 }
      set %autom.srepon $did(14).state 
    }
    if $did == 23 { set %autom.mrepon 23 }
    if $did == 24 { set %autom.mrepon 24 }
  }
  if $did(4).state == 1 {
    if $did == 12 { var %text = $$?="Entre un nouveau texte" | write TXT\op.txt %text | did -a autom 11 %text }
    if $did == 13 { if $did(11).sel { var %text = $did(11).seltext | var %m = $read -s [ $+ [ %text ] ] TXT\op.txt | var %l = $readn | write -dl $+ %l  TXT\op.txt | did -d autom 11 $did(11).sel | did -i autom 22 1 text +m $crlf } | Else { var %errff = $input(Aucune sélection,100,Information) } }
    if $did == 14 {
      if $did(14).state == 1 { did -e autom 15,16,17 }
      if $did(14).state == 0 { did -b autom 15,16,17 }
      set %autom.sop $did(14).state 
    }
    if $did == 15 { set %autom.mop 15 }
    if $did == 16 { set %autom.mop 16 }
    if $did == 17 { set %autom.mop 17 }
  }
  if $did(5).state == 1 {
    if $did == 12 { var %text = $$?="Entre un nouveau texte" | write TXT\deop.txt %text | did -a autom 11 %text }
    if $did == 13 { if $did(11).sel { var %text = $did(11).seltext | var %m = $read -s [ $+ [ %text ] ] TXT\deop.txt | var %l = $readn | write -dl $+ %l  TXT\deop.txt | did -d autom 11 $did(11).sel | did -i autom 22 1 text +m $crlf } | Else { var %errff = $input(Aucune sélection,100,Information) } }
    if $did == 14 {
      if $did(14).state == 1 { did -e autom 15,16,17 }
      if $did(14).state == 0 { did -b autom 15,16,17 }
      set %autom.sdeop $did(14).state 
    }
    if $did == 15 { set %autom.mdeop 15 }
    if $did == 16 { set %autom.mdeop 16 }
    if $did == 17 { set %autom.mdeop 17 }
  }
  if $did(7).state == 1 {
    if $did == 12 { var %text = $$?="Entre un nouveau texte" | write TXT\voice.txt %text | did -a autom 11 %text }
    if $did == 13 { if $did(11).sel { var %text = $did(11).seltext | var %m = $read -s [ $+ [ %text ] ] TXT\voice.txt | var %l = $readn | write -dl $+ %l  TXT\voice.txt | did -d autom 11 $did(11).sel | did -i autom 22 1 text +m $crlf } | Else { var %errff = $input(Aucune sélection,100,Information) } }
    if $did == 14 {
      if $did(14).state == 1 { did -e autom 15,16,17 }
      if $did(14).state == 0 { did -b autom 15,16,17 }
      set %autom.svoice $did(14).state 
    }
    if $did == 15 { set %autom.mvoice 15 }
    if $did == 16 { set %autom.mvoice 16 }
    if $did == 17 { set %autom.mvoice 17 }
  }
  if $did(6).state == 1 {
    if $did == 12 { var %text = $$?="Entre un nouveau texte" | write TXT\devoice.txt %text | did -a autom 11 %text }
    if $did == 13 { if $did(11).sel { var %text = $did(11).seltext | var %m = $read -s [ $+ [ %text ] ] TXT\devoice.txt | var %l = $readn | write -dl $+ %l  TXT\devoice.txt | did -d autom 11 $did(11).sel | did -i autom 22 1 text +m $crlf } | Else { var %errff = $input(Aucune sélection,100,Information) } }
    if $did == 14 {
      if $did(14).state == 1 { did -e autom 15,16,17 }
      if $did(14).state == 0 { did -b autom 15,16,17 }
      set %autom.sdevoice $did(14).state 
    }
    if $did == 15 { set %autom.mdevoice 15 }
    if $did == 16 { set %autom.mdevoice 16 }
    if $did == 17 { set %autom.mdevoice 17 }
  }
  if $did(9).state == 1 {
    if $did == 12 { var %text = $$?="Entre un nouveau texte" | write TXT\kick.txt %text | did -a autom 11 %text }
    if $did == 13 { if $did(11).sel { var %text = $did(11).seltext | var %m = $read -s [ $+ [ %text ] ] TXT\kick.txt | var %l = $readn | write -dl $+ %l  TXT\kick.txt | did -d autom 11 $did(11).sel | did -i autom 22 1 text +m $crlf } | Else { var %errff = $input(Aucune sélection,100,Information) } }
    if $did == 14 {
      if $did(14).state == 1 { did -e autom 16,17 }
      if $did(14).state == 0 { did -b autom 16,17 }
      set %autom.skick $did(14).state 
    }
    if $did == 15 { set %autom.mkick 15 }
    if $did == 16 { set %autom.mkick 16 }
    if $did == 17 { set %autom.mkick 17 }
  }
  if $did(8).state == 1 {
    if $did == 12 { var %text = $$?="Entre un nouveau texte" | write TXT\ban.txt %text | did -a autom 11 %text }
    if $did == 13 { if $did(11).sel { var %text = $did(11).seltext | var %m = $read -s [ $+ [ %text ] ] TXT\ban.txt | var %l = $readn | write -dl $+ %l  TXT\ban.txt | did -d autom 11 $did(11).sel | did -i autom 22 1 text +m $crlf } | Else { var %errff = $input(Aucune sélection,100,Information) } }
    if $did == 14 {
      if $did(14).state == 1 { did -e autom 15,16,17 }
      if $did(14).state == 0 { did -b autom 15,16,17 }
      set %autom.sban $did(14).state 
    }
    if $did == 15 { set %autom.mban 15 }
    if $did == 16 { set %autom.mban 16 }
    if $did == 17 { set %autom.mban 17 }
  }
}
on *:join:*:{ if $nick == $me { if %autom.sjoin == 1 { say $read(TXT\join.txt) } } }
on *:op:*:{ if $opnick == $me { if %autom.sop == 1 { $decodeautom(%autom.mop,#,$nick) $read(TXT\op.txt) } } }
on *:deop:*:{ if $opnick == $me { if %autom.sdeop == 1 { $decodeautom(%autom.mdeop,#,$nick) $read(TXT\deop.txt) } } }
on *:voice:*:{ if $vnick == $me { if %autom.svoice == 1 { $decodeautom(%autom.mvoice,#,$nick) $read(TXT\voice.txt) } } }
on *:devoice:*:{ if $vnick == $me { if %autom.sdevoice == 1 { $decodeautom(%autom.mdevoice,#,$nick) $read(TXT\devoice.txt) } } }
on *:kick:*:{ if $knick == $me { if %autom.skick == 1 { $decodeautom(%autom.mkick,#,$nick) $read(TXT\kick.txt) } } }
on *:ban:*:{ if $bnick == $me { if %autom.sban == 1 { $decodeautom(%autom.mban,#,$nick) $read(TXT\ban.txt) } } }
on *:open:?:{ if %autom.srepon == 1 { if %autom.mrepon == 23 { msg $nick $read(TXT\repon.txt) } | if %autom.mrepon == 24 { close -m $nick | .msg $nick $read(TXT\repon.txt) } } }
alias decodeautom {
  if $1 == 15 { return .msg $2 }
  if $1 == 16 { return .notice $3 }
  if $1 == 17 { return .msg $3 }
}
