**********************************************
VEGETA T v2.0
By uN|x
Official Home Page www.ircvegetascript.cjb.net
E-mail ircvegetascript@email.it
**********************************************

alias ajoin {
  dialog -m autoj autoj
}
dialog autoj {
  title "AutoJoin"
  size -1 -1 225 218
  button "CHIUDI",1,10 192 204 20, OK
  box "", 30, 3 -1 218 182 
  text "Channels List:",13, 10 10 94 25
  combo 14,10 30 120 145,sort
  button "Add Chan",15, 135 30 77 20
  button "Remove Chan",16, 135 60 77 20
  button "Join Chan",17, 135 84 77 20
  check "",18, 139 144 69 22, push
  box "", 40, 135 133 77 38
  button "Clear List",22, 135 109 77 20
  box "", 23, -20 180 250 200
}
on *:DIALOG:autoj:init:0: {
  did -b autoj 15
  did -b autoj 16
  did -b autoj 17
  did -a autoj 18 %ajoin.status
  if (%setup.connect == $null) { set %setup.connect off }
  if (%setup.connect == on) { did -c autoj 18 }
  update.setup
}
alias -l update.setup {
  did -r autoj 14
  set %temp.total $count(%setup.list,$chr(44))
  set %temp.count 0
  :start
  inc %temp.count 1
  did -a autoj 14 $gettok(%setup.list,%temp.count,44)
  if (%temp.count < %temp.total) { goto start }
}
on *:DIALOG:autoj:edit:*: {
  if ($did == 14) {
    set %setup.temp.channel $did(14).text
    did -e autoj 15
  }
}
on *:DIALOG:autoj:sclick:*: {
  if ($did == 22) {
    unset %setup.list
    update.setup
  } 
  if ($did == 15) {
    set %setup.list %setup.list $+ %setup.temp.channel $+ ,
    update.setup
  }
  if ($did == 16) {
    set -u1 %setup.tc %setup.channel.selected $+ ,
    set %setup.list $remove(%setup.list,%setup.tc)
    update.setup
  }
  if ($did == 17) {
    join %setup.channel.selected
  }
  if ($did == 14) {
    set %setup.channel.selected $did($dname,14,$did(14).sel)
    did -e autoj 16
    did -e autoj 17
  }
  if ($did == 18) {
    if (%setup.connect == on) { set %setup.connect off | set %ajoin.status Status: off | did -a autoj 18 %ajoin.status | halt }
    if (%setup.connect == off) { set %setup.connect on | set %ajoin.status Status: on | did -a autoj 18 %ajoin.status | halt }
  }
  if ($did == 1) {

  }
}
on *:CONNECT: {
  if (%setup.connect == on) {
    set %temp.total $count(%setup.list,$chr(44))
    set %temp.count 0
    :start
    inc %temp.count 1
    .timer 1 3 join $gettok(%setup.list,%temp.count,44)
    if (%temp.count < %temp.total) { goto start }
  }
}
