;IRcap8 bbb1806780975491c74f1306f2db81f8

alias cbots2 {
  if (!$s(1)) { .hmake -s tool | .hload tool "lng\ $+ %idioma $+ \tool.lnh" }
  unset %cbots.*
  if $2 != - { %cbots.canal = $2 }
  if $3 != - { %cbots.nick = $3 }
  %cbots.mn = $remove($gettok(%netcon. [ $+ [ $cid ] ],1,32),.inb)
  window -c @cbots | guiwin @cbots c c 600 390 $s(120) : $Nnet
  %cbots.pñ1 = 40 60 $iif(%cbots.mn == undernet || %cbots.mn == quakenet,1,$1) botgui $ [ $+ [ %cbots.mn $+ .nombrecbots ] ]
  window -lh @cbots1 | window -lh @cbots2 | clear @cbots2
  %cbots.ls1 = 28 88 120 18 1 0 botexec @cbots1 arbol
  %cbots.ls2 = 180 144 372 14 1 0 cbotnosel @cbots2
  botgui
}
alias -l S return $hget(tool,$1)


alias botgui {
  cuag @cbots 16 60 568 312 gui
  pestana @cbots cbots.pñ1

  cuagr @cbots 32 80 84 14 $s(121)
  cuagr @cbots 180 88 392 36 $s(122)
  %cbots.tx = 236 100 110 cbots.canal $s(62) |428 100 110 cbots.nick $s(123)
  %cbots.bt = 28 346 8 cbots.exe >|60 346 8 cbots.ayuda ?|180 346 180 f3_setNETW $s(124) |390 346 74 cbots.cls $s(125)

  clear @cbots1 | %cbots.mn $+ .CBOTCOM- $+ $gettok(%cbots.pñ1,3,32) n

  guilista @cbots cbots.ls1
  guilista @cbots cbots.ls2

  guidib @cbots
  window -wa @cbots
}

alias BOTEXEC {
  if $1 == sm { var %c = $2- | goto L1 }

  if ($gettok($3-,2,8) == g) && ($1 == 2) {
    var %i = $gettok($3-,1,8) 
    var %a = $gettok($3-,6,8) | inc %a | if %a > 2 { var %a = 1 } | $larbol(@cbots1,$puttok($3-,%a,6,8)).ana | if (%a == 2) { $larbol(@cbots1,%i).delg | %cbots.kesaco = $remove(%cbots.kesaco,%i) }
    sline -r @cbots1
    if (%a == 1) { %cbots.kesaco = $remove(%cbots.kesaco,%i) $+ %i | clear @cbots1 | %cbots.mn $+ .CBOTCOM- $+ $gettok(%cbots.pñ1,3,32) %i }
    guilista @cbots cbots.ls1 | guidib @cbots
    return
  }

  if $1 == 2 {
    var %a = $gettok($1-,4,8)

    if (&c isin %a) { var %can = %cbots.canal | if (!%can) { var %can = #$$?=" $mg(canal) " } }
    if (&n isin %a) { var %nik = %cbots.nick | if (!%nik) { var %nik = $$?=" $mg(nick) " } }
    if (?raz isin %a) { var %raz = $?=" $s(126) " }
    if (?txt isin %a) { var %txt = $?=" $s(127) " }
    if (?pas isin %a) { var %pas = $dapass(nick. $+ $nnet,$me) | if (!%pas) { var %pas = $$?*=" $mg(ppass) " } }
    if (?ppas isin %a) { var %ppas = $$?*=" $mg(ppass) " }
    if (?cpas isin %a) { var %cpas = $dapass(canal. $+ $nnet,%can) | if (!%cpas) { var %cpas = $$?*=" $mg(ppass) " } }
    if (?cppas isin %a) { var %cppas = $$?*=" $mg(ppass) " }
    if (?mail isin %a) { var %mail = $$?=" $mg(pmail) " }
    if (?mask isin %a) { var %mask = $$?=" $mg(ipmask) " }
    if (?niv isin %a) { var %niv = $$?=" $mg(pnivel) " }
    if (?slev isin %a) { var %slev = $?=" $mg(pnivel)  (en blanco, resetea)" | if (!%slev) { %a = $puttok(%a,dis,3,32) | %a = $remove(%a,?slev) } }
    if (?num isin %a) { var %num = $$?=" $mg(num) " }

    var %c = $replace(%a,&c,%can,&n,%nik,?raz,%raz,?txt,%txt,?pas,%pas,?ppas,%ppas,?cpas,%cpas,?cppas,%cppas,?mail,%mail,?mask,%mask)
    var %c = $replace(%c,?niv,%niv,?slev,%slev,?num,%num)

    if (<npass> isin %c) { %c = $remove(%c,<npass>) | var %npass = 1 }
    if (<cpass> isin %c) { %c = $remove(%c,<cpass>) | var %npass = 2 }

    if (<conf> isin %c) { %c = $remove(%c,<conf>) | var %z = $?!=" $s(128) $crlf $crlf $replace(%c,%pas,***,%ppas,***,%cpas,***,%cppas,***) " | if (!%z) return }
    if (?run isin %c) { .timer -m 1 100 $remove(%c,?run) | return }
    if ( isin %c) { 
      var %s = $gettok(%c,2-,15) | %c = $gettok(%c,1,15)
      %tmp.cbots.c = %c | %tmp.cbots.s = %s
      smenu botexec-sm 50 %s
      return
    }

    :L1
    cbotinfo --> %c
    if (msg isin $gettok(%cbots.p %c,1,32)) { .auser 96,69 $gettok(%cbots.p %c,2,32)) }
    %cbots.p %c

    if %npass == 1 { adpass nick. $+ $nnet $me %ppas }
    if %npass == 2 { adpass canal. $+ $nnet %can %cppas }
  }
}
alias BOTEXEC-sm {
  %tmp.cbots.s = $gettok(%tmp.cbots.s,$1,22)
  botexec sm %tmp.cbots.c %tmp.cbots.s
}

alias CBOTINFO {
  if $1 == refres { guilista @cbots cbots.ls2 | drawline @cbots | return }

  if (%cbots.sep != $timestamp) { aline @cbots2 $str(- ,60) $+ ( $strip($timestamp) ) | %cbots.sep = $timestamp }

  var %l = $1- | if $2 == * { %l = $1 $3 ****** }

  var %n = $wrap(%l,verdana,9,364,0) , %i = 1 | while (%i <= %n) { aline @cbots2 $wrap($strip(%l,c),verdana,9,364,%i) | inc %i }

  if ($line(@cbots2,0) > 99) { dline @cbots2 1 }

  %cbots.ls2 = $puttok(%cbots.ls2,$line(@cbots2,0),5,32)
  %cbots.ls2 = $puttok(%cbots.ls2,0,6,32)
  .timerCBOTINFO -m 1 150 cbotinfo refres
}
alias cbotnosel sline -r @cbots2 | cbotinfo refres

alias cbots.exe if ($gettok($sline(@cbots1,1),2,8) == i) botexec 2 $sline(@cbots1,1)
alias cbots.ayuda {
  if (!$sline(@cbots1,1)) && (!%cbots.p) return
  var %c = help $gettok($gettok($sline(@cbots1,1),4,8),1,32)
  if (!%cbots.p) { %c = $instok($gettok($gettok($sline(@cbots1,1),4,8),1-3,32),help,3,32) } 
  if (!%cbots.p) && (%c isin help) { %c = .msg $strip($gettok($sline(@cbots1,1),3,8)) help }
  %cbots.p %c | cbotinfo --> %c
}
alias cbots.cls clear @cbots2 | cbotinfo refres

alias cbots.cierra unset %cbots.* | .timer 1 2 tolhfree | .rlevel 96 | .unload -rs $shortfn($script)

;EOF-dt
