Xdcc autoleech

Description

Ce code permet de faciliter la download depuis un bot XDCC. Les 3 commandes de base sont disponibles rapidement en faisant un petit clic-droit sur le nick du bot. Si vous voulez dévaliser un bot XDCC de sont contenu, il vous est possible d'automatiser la download en passant par la commande AutoLeech. Cette dernière permet de gérer la file d'attente visuellement, de modifier cette dernière à n'importe quel moment et de reprendre les downloads interrompues. De plus la liste des packs normalement envoyée par un bot directement en notice dans le chan, est maintenant stockée dans une fenêtre séparée, afin d'avoir une liste propre facilement consultable.
Le script permet de gérer plusieurs bot en même temps sur différents réseaux.

Source / Exemple :


dialog AutoLeech_main {
  title "AutoLeech"
  size -1 -1 160 90
  option dbu
  box "AutoLeech List:", 1, 2 2 152 82
  list 2, 5 10 100 70, size
  button "Edit", 11, 110 10 40 12
  button "Delete", 12, 110 24 40 12
  button "Resume All", 13, 110 38 40 12
  button "Ok", 14, 110 68 40 12, ok cancel
}
on *:dialog:AutoLeech_main:*:*:{
  if ($devent == init) didtok AutoLeech_main 2 32 $GetAutoLeechNickList
  elseif ($devent == dclick) if (($did == 2) && ($did(2).sel)) dialog -m AutoLeech_edit AutoLeech_edit
  elseif ($devent == sclick) {
    if (($did == 11) && ($did(2).sel)) dialog -m AutoLeech_edit AutoLeech_edit
    elseif (($did == 12) && ($did(2).sel)) {
      .timerAutoLeech_ [ $+ [ $did(2,$did(AutoLeech_main,2).sel).text ] ] off
      msg $did(AutoLeech_main,2,$did(2).sel).text xdcc remove
      echo -s 14AutoLeech on15 $did(2,$did(2).sel).text 4canceled.
      unset %AutoLeech_ [ $+ [ $did(2,$did(2).sel).text ] ]
      if ($did(2,$did(2).sel).text isin %AutoLeechList) {
        set %AutoLeechList $remtok(%AutoLeechList, $wildtokcs(%AutoLeechList, $did(2,$did(2).sel).text $+ $chr(44) $+ *,1,32),1,32)
        if (%AutoLeechList == $null) unset %AutoLeechList
      }
      did -r AutoLeech_main 2
      didtok AutoLeech_main 2 32 $GetAutoLeechNickList
    }
    elseif (($did == 13) && (%AutoLeechList)) {
      var %j 1
      while (%j <= $numtok(%AutoLeechList,32)) {
        if ($gettok( $gettok(%AutoLeechList, %j, 32), 2, 44) == $network) ResumeAutoLeechXDCC $gettok( $gettok(%AutoLeechList,%j,32),1,44)
        inc %j
      }
    }
  }
}
dialog AutoLeech_add {
  title "AutoLeech Add"
  size -1 -1 160 120
  option dbu
  box "Pack selection : ", 1, 5 5 150 80
  radio "Packs : ", 10, 10 15 30 10
  radio "From file : ", 20, 10 55 35 10
  edit "",11, 10 25 140 10
  edit "",21, 10 65 123 10
  text "Type in the packs n° and/or the packs groups to download, separated by dots. Ex: 1.3.5-12.14", 12, 15 37 140 15
  button "...", 22, 135 65 15 10
  button "Ok", 100, 100 100 40 12, ok cancel
}
on *:dialog:AutoLeech_add:*:*:{
  if ($devent == init) {
    did -c AutoLeech_add 10
    did -f AutoLeech_add 11
    did -b AutoLeech_add 21,22
    did -t AutoLeech_add 100
    set %old_input
  }
  elseif ($devent == sclick) {
    if ($did == 10) {
      did -e AutoLeech_add 11
      did -b AutoLeech_add 21,22
    }    
    elseif ($did == 20) {
      did -b AutoLeech_add 11
      did -e AutoLeech_add 21,22
    }
    elseif ($did == 22) {
      var %AutoLeech_Pack_List = $sfile($mircdir,Select a pack list,Select)
      $iif(!%AutoLeech_Pack_List,return)
      did -o AutoLeech_add 21 1 %AutoLeech_Pack_List
    }
    elseif ($did == 100) {
      if (%AutoLeech_add_mode == add) {
        if (($did(10).state) && ($did(AutoLeech_add,11))) AddAutoLeechXDCC %AutoLeech_add_Nick $did(11)
        else if ($did(21)) AddAutoLeechXDCC %AutoLeech_add_Nick " $+ $did(21) $+ "
      }
      did -r AutoLeech_edit 1,2,3
      didtok AutoLeech_edit 1 46 $GetWaiting(%AutoLeech_edit_Nick)
      didtok AutoLeech_edit 2 46 $GetActive(%AutoLeech_edit_Nick)
      didtok AutoLeech_edit 3 46 $GetCompleted(%AutoLeech_edit_Nick)
    }
    else {
      if ($did(10).state) if ($did(11)) AutoLeechXDCC %AutoLeech_add_Nick $did(11)
      else if ($did(21)) AutoLeechXDCC %AutoLeech_add_Nick " $+ $did(21) $+ "
    }
  }
  elseif ($devent == edit) {
    if ($did == 11) {
      if (($right($did(11),1) == $chr(45)) || ($right($did(11),1) == $chr(46)) || ($right($did(11),1) isnum) || ($did(11) == $null)) {
        set %old_input $did(11)
      }
      else {
        did -i AutoLeech_add 11 1 %old_input
        did -c AutoLeech_add 11 1 $calc($len($did(11)) + 1)
      }
    }
  }
  elseif ($devent == close) unset %AutoLeech_add_Nick , %old_input , %AutoLeech_add_mode
}
dialog AutoLeech_edit {
  title "AutoLeech Details"
  size -1 -1 192 105
  option dbu
  list 1, 5 10 40 70, size
  list 2, 100 10 40 70, size
  list 3, 145 10 40 70, size
  text "Active List:", 5, 101 2 40 8
  text "Completed List:", 6, 146 2 40 8
  box "Waiting List:", 4, 2 2 91 82
  button "Add", 10, 50 10 40 12
  button "Edit", 11, 50 24 40 12
  button "Delete", 12, 50 38 40 12
  button "Clear All", 13, 50 68 40 12
  button "Resume AutoLeech", 14, 5 87 85 12
  button "Refresh", 15, 100 87 40 12
  button "Ok", 100, 145 87 40 12, ok cancel
}
on *:dialog:AutoLeech_edit:*:*:{
  if ($devent == init) {
    if ( %AutoLeech_edit_Nick == $null ) set %AutoLeech_edit_Nick $did(AutoLeech_main,2,$did(AutoLeech_main,2).sel).text
    did -r AutoLeech_edit 1,2,3
    didtok AutoLeech_edit 1 46 $GetWaiting(%AutoLeech_edit_Nick)
    didtok AutoLeech_edit 2 46 $GetActive(%AutoLeech_edit_Nick)
    didtok AutoLeech_edit 3 46 $GetCompleted(%AutoLeech_edit_Nick)
  }
  elseif (($devent == dclick) && ($did == 1)) {
    var %waiting_list $GetWaiting( %AutoLeech_edit_Nick )
    var %selected_pack $did(1,$did(1).sel).text
    var %input $$?="Type in the pack n°"
    set %input $CheckInput(%input)
    if (( %input ) && ($istok( %waiting_list, %input, 46) == $false)) {
      SetWaiting %AutoLeech_edit_Nick $reptok( %waiting_list, %selected_pack, %input,1,46)
      did -r AutoLeech_edit 1
      didtok AutoLeech_edit 1 46 $GetWaiting( %AutoLeech_edit_Nick)
      echo -s 14Pack15 %selected_pack 14changed to pack15 %input 14in15 %AutoLeech_edit_Nick $+ 's 14waiting list
    }
  }
  elseif ($devent == sclick) {
    if ($did == 10) {
      set %AutoLeech_add_Nick %AutoLeech_edit_Nick
      set %AutoLeech_add_mode add
      dialog -m AutoLeech_add AutoLeech_add
    }
    elseif ($did == 11) && ($did(1).sel) {
      var %waiting_list $GetWaiting( %AutoLeech_edit_Nick )
      var %selected_pack $did(1,$did(1).sel).text
      var %input $$?="Type in the new pack n°"
      set %input $CheckInput(%input)
      if (( %input ) && ($istok( %waiting_list, %input, 46) == $false)) {
        SetWaiting %AutoLeech_edit_Nick $reptok( %waiting_list, %selected_pack, %input,1,46)
        did -r AutoLeech_edit 1
        didtok AutoLeech_edit 1 46 $GetWaiting( %AutoLeech_edit_Nick)
        echo -s 14Pack15 %selected_pack 14changed to pack15 %input 14in15 %AutoLeech_edit_Nick $+ 's 14waiting list
      }
    }
    elseif ($did == 12) && ($did(1).sel) {
      var %waiting_list $GetWaiting( %AutoLeech_edit_Nick )
      var %selected_pack $did(1,$did(1).sel).text
      SetWaiting %AutoLeech_edit_Nick $remtok( %waiting_list, %selected_pack, 1 ,46)
      did -r AutoLeech_edit 1
      didtok AutoLeech_edit 1 46 $GetWaiting( %AutoLeech_edit_Nick)
      echo -s 14Pack15 %selected_pack 14removed from15 %AutoLeech_edit_Nick $+ 's 14waiting list
    }
    elseif ($did == 13) {
      SetWaiting %AutoLeech_edit_Nick 0
      did -r AutoLeech_edit 1
      didtok AutoLeech_edit 1 46 $GetWaiting(%AutoLeech_edit_Nick)
      echo -s 14All packs 14removed from15 %AutoLeech_edit_Nick $+ 's 14waiting list
    }
    elseif ($did == 14) {
      ResumeAutoLeechXDCC %AutoLeech_edit_Nick
    }
    elseif ($did == 15) {
      did -r AutoLeech_edit 1,2,3
      didtok AutoLeech_edit 1 46 $GetWaiting(%AutoLeech_edit_Nick)
      didtok AutoLeech_edit 2 46 $GetActive(%AutoLeech_edit_Nick)
      didtok AutoLeech_edit 3 46 $GetCompleted(%AutoLeech_edit_Nick)
    }
  }
  elseif ($devent == close) {
    unset %AutoLeech_edit_Nick
  }
}
menu menubar {
  $iif(!$dialog(AutoLeech_main),XDCC AutoLeech):dialog -m AutoLeech_main AutoLeech_main
}
menu Nicklist {
  $iif(($1 !isreg #),$iif(((*[*]* iswm $1 || *XDCC* iswm $1 || *|* iswm $1) && *FSERV* !iswm $1),XDCC,XDCC (Forced)),$style(2) XDCC)
  .$iif((%AutoLeech_ [ $+ [ $1 ] ]),$style(2) Send pack...,Send pack...):msg $$1 xdcc send #$$?="Pack number :"
  .Info pack...:msg $$1 xdcc info #$$?="Pack number :"
  .List:{ 
    msg $$1 xdcc list
    window -lk0 @XDCC_list
    set -z %AutoLeechRequestedList_ [ $+ [ $1 ] ] 30
  }
  .-
  .$iif(( %AutoLeech_ [ $+ [ $1 ] ] ),$style(2) AutoLeech on $1...,AutoLeech on $1...):set %AutoLeech_add_Nick $1 | dialog -m AutoLeech_add AutoLeech_add
  .$iif(( %AutoLeech_ [ $+ [ $1 ] ] ),Manage...):set %AutoLeech_edit_Nick $1 | dialog -m AutoLeech_edit AutoLeech_edit
  .$iif(( %AutoLeech_ [ $+ [ $1 ] ] ),Resume):ResumeAutoLeechXDCC $1
  .$iif(( %AutoLeech_ [ $+ [ $1 ] ] ),Cancel):{
    msg $1 xdcc remove
    echo -s 14AutoLeech on 15 $+ $1 4canceled.
    .timerAutoLeech_ [ $+ [ $1 ] ] off
    unset %AutoLeech_ [ $+ [ $1 ] ]
    if ($1 isin %AutoLeechList) {
      set %AutoLeechList $remtok(%AutoLeechList, $matchtok(%AutoLeechList, $1, 1, 32), 1, 32)
      if (%AutoLeechList == $null) unset %AutoLeechList
    }
  }
}
alias -l CheckInput if (($1 isnum) && ($chr(46) !isin $1) && ($1 > 0)) return $1
alias -l GetSettings return $gettok( %AutoLeech_ [ $+ [ $1 ] ], $2, 32)
alias -l GetWaiting return $GetSettings($1, 1)
alias -l GetWaitingNumber {
  if ($GetWaiting($1) == 0) return 0
  else return $numtok( $GetWaiting($1), 46)
}
alias -l GetWaitingPack return $gettok( $GetWaiting($1), $2, 46)
alias -l GetActive return $GetSettings($1, 2)
alias -l GetActiveNumber {
  if ($GetActive($1) == 0) return 0
  else return $numtok( $GetActive($1), 46)
}
alias -l GetActivePack return $gettok( $GetActive($1), $2, 46)
alias -l GetCompleted return $GetSettings($1, 3)
alias -l GetCompletedNumber {
  if ($GetCompleted($1) == 0) return 0
  else return $numtok( $GetCompleted($1), 46)
}
alias -l GetCompletedPack return $gettok( $GetCompleted($1), $2, 46)
alias -l GetTotalNumber return $calc( $GetWaitingNumber($1) + $GetActiveNumber($1) + $GetCompletedNumber($1))
alias -l GetAutoLeechNickList {
  if (%AutoLeechList) {
    var %result
    var %i 1
    while (%i <= $numtok(%AutoLeechList, 32)) {
      set %result $addtok(%result, $deltok($gettok(%AutoLeechList, %i,32),2,44),32)
      inc %i
    }
    return %result
  }
}
alias -l SetSetting set %AutoLeech_ [ $+ [ $1 ] ] $puttok( %AutoLeech_ [ $+ [ $1 ] ], $2, $3,32)
alias -l SetWaiting SetSetting $1 $2 1
alias -l SetActive SetSetting $1 $2 2
alias -l SetCompleted SetSetting $1 $2 3
alias -l MovetoWaiting {
  if ($GetActive($1) != 0) { 
    if ($GetWaiting($1) == 0) SetWaiting $1 $gettok( $GetActive($1), $GetActiveNumber($1), 46)
    else SetWaiting $1 $instok( $GetWaiting($1), $gettok( $GetActive($1), $GetActiveNumber($1), 46), 1, 46)
    if ($GetActiveNumber($1) == 1) SetActive $1 0
    else SetActive $1 $deltok( $GetActive($1), $GetActiveNumber($1), 46)
  }
}
alias -l MoveFailedtoWaiting {
  if ($GetActive($1) != 0) { 
    if ($GetWaiting($1) == 0) SetWaiting $1 $gettok( $GetActive($1), 1, 46)
    else SetWaiting $1 $instok( $GetWaiting($1), $gettok( $GetActive($1), 1, 46), 1, 46)
    if ($GetActiveNumber($1) == 1) SetActive $1 0
    else SetActive $1 $deltok( $GetActive($1), 1, 46)
  }
}
alias -l MovetoActive {
  if ($GetWaiting($1) != 0) { 
    if ($GetActive($1) == 0) SetActive $1 $GetWaitingPack($1,1)
    else SetActive $1 $addtok( $GetActive($1), $GetWaitingPack($1,1), 46)
    if ($GetWaitingNumber($1) == 1) SetWaiting $1 0
    else SetWaiting $1 $deltok( $GetWaiting($1), 1, 46)
  }
}
alias -l MovetoCompleted {
  if ($GetActive($1) != 0) { 
    if ($GetCompleted($1) == 0) SetCompleted $1 $GetActivePack($1,1)
    else SetCompleted $1 $addtok( $GetCompleted($1), $gettok( $GetActive($1), 1, 46), 46)
    if ($GetActiveNumber($1) == 1) SetActive $1 0
    else SetActive $1 $deltok( $GetActive($1), 1, 46)
  }
}
alias -l CreatList {
  var %entry $1
  var %result
  var %i = 1
  while (%i <= $numtok(%entry,46)) {
    if ( - isin $gettok( %entry, [ %i ],46) ) {
      var %low $gettok($gettok( %entry, [ %i ],46),1,45)
      var %up $gettok($gettok( %entry, [ %i ],46),2,45)
      if (%low > %up) {
        var %temp = %low
        %low = %up
        %up = %temp
      }
      while (%low <= %up ) {
        set %result $addtok( %result, %low, 46)
        inc %low
      }
    }
    else set %result $addtok( %result, $gettok( %entry, [ %i ],46), 46)
    inc %i
  }
  set %result $sorttok( %result ,46,n)
  return $remtok( %result, 0, 46)
}
alias CreatListFromFile {
  var %result
  if (($isfile($1)) && ($lines($1) > 0)) {
    var %i = 1
    var %temp
    while (%i <= $lines($1)) {
      set %temp $gettok($read($1,nt,%i), 1, 32)
      set %temp $CheckInput( $remove(%temp,$chr(9),$chr(35)) )
      if ( %temp ) set %result $addtok( %result, %temp, 46)
      inc %i
    }
    if (%result == $null) {
      echo 14Space separator isn't working. Trying tab separator
      var %i = 1
      while (%i <= $lines($1)) {
        set %temp $gettok($read($1,nt,%i), 1, 9)
        set %temp $CheckInput( $remove(%temp,$chr(32),$chr(35)) )
        if ( %temp ) set %result $addtok( %result, %temp, 46)
        inc %i
      }
    }
    if (%result == $null) {
      echo 14Trying an alternative tab separator setting.
      var %i = 1
      while (%i <= $lines($1)) {
        set %temp $gettok($read($1,nt,%i), 2, 9)
        set %temp $CheckInput( $remove(%temp,$chr(32),$chr(35)) )
        if ( %temp ) set %result $addtok( %result, %temp, 46)
        inc %i
      }
    }
  }
  set %result $sorttok( %result ,46,n)
  return $remtok( %result, 0, 46)
}
alias -l QueueNext {
  if ($GetWaitingPack($1,1) != 0) {
    msg $1 xdcc send $GetWaitingPack($1,1)
    MovetoActive $1
    echo -s 14Queueing Pack : 15 $+ $calc($GetActiveNumber($1) + $GetCompletedNumber($1)) $+ 14 $+ $chr(47) $+ 15 $+ $GetTotalNumber($1)
  }
}
alias -l AutoLeechXDCC {
  if ($left($2,1) == $chr(34)) set %AutoLeech_ [ $+ [ $1 ] ] $CreatListFromFile($2-)
  else set %AutoLeech_ [ $+ [ $1 ] ] $CreatList($2)
  if (%AutoLeech_ [ $+ [ $1 ] ]) {
    set %AutoLeech_ [ $+ [ $1 ] ] $addtok( %AutoLeech_ [ $+ [ $1 ] ], 0 $+ $chr(32) $+ 0, 32)
    set %AutoLeechList $addtok(%AutoLeechList, $1 $+ $chr(44) $+ $network, 32)
    QueueNext $1
    if ($GetWaitingNumber($1) > 0) .timerAutoLeech_ [ $+ [ $1 ] ] $GetWaitingNumber($1) 20 QueueNext $1
  }
  else {
    echo -s 14AutoLeech 4aborted. 14(No valid pack n°)
    unset %AutoLeech_ [ $+ [ $nick ] ]
  }
}
alias -l AddAutoLeechXDCC {
  if ($left($2,1) == $chr(34)) var %FilestoAdd = $CreatListFromFile($2-)
  else var %FilestoAdd = $CreatList($2)
  var %j = 1
  var %i = 0
  var %temp
  if ($GetWaiting($1) != 0) set %temp $GetWaiting($1)
  while (%j <= $numtok(%FilestoAdd,46)) {
    if (($istok($GetWaiting($1),$gettok(%FilestoAdd, %j,46),46) == $false) && ($istok($GetActive($1),$gettok(%FilestoAdd, %j,46),46) == $false) && ($istok($GetCompleted($1),$gettok(%FilestoAdd, %j,46),46) == $false)) {
      set %temp $addtok( %temp,$gettok( %FilestoAdd, %j,46),46)
      inc %i
    }
    inc %j
  }
  echo -s 15 $+ %i $iif((%i > 1), 14files, 14file) $+ $chr(32) $+ added in15 $1 $+ 14 $+ $chr(39) $+ s AutoLeech list
  if (%i > 0) {
    SetWaiting $1 %temp
    if ($GetWaitingNumber($1) == %i) .timerAutoLeech_ [ $+ [ $1 ] ] %i 20 QueueNext $1
  }
}
alias -l ResumeAutoLeechXDCC {
  echo -s 14AutoLeech on15 $1 14resuming.
  while ($GetActiveNumber($1) > 0) {
    MovetoWaiting $1
  }
  QueueNext $1
  if ($GetWaitingNumber($1) > 0) .timerAutoLeechResuming_ [ $+ [ $1 ] ] $GetWaitingNumber($1) 20 QueueNext $1
}
ctcp *:DCC SEND*:*:{
  if (%AutoLeech_ [ $+ [ $nick ] ] ) {
    var %size
    if ($6 >= 1024000) set %size $bytes( $6, m3d) $+ $chr(32) $+ Megas
    elseif ($6 >= 1000) set %size $bytes( $6, k3d) $+ $chr(32) $+ Kb
    else set %size $bytes( $6, b3d) $+ $chr(32) $+ bytes
    echo -s 14Sending of15 $3 14which is15 %size 14started
    if ($GetWaitingNumber($nick) > 1) {
      echo -s 14Queueing next 15->
      .timer 1 10 QueueNext $nick
    }
    elseif ($GetWaitingNumber($nick) == 1) {
      echo -s 14Queueing last one 15->
      .timer 1 10 QueueNext $nick
    }
  }
}
on 1:FILERCVD:*:{
  if (%AutoLeech_ [ $+ [ $nick ] ] ) {
    MovetoCompleted $nick
    echo -s 15AutoLeech on $nick
    echo -s 14Pack :15 $GetCompletedNumber($nick) $+ 14 $+ $chr(47) $+ 15 $+ $GetTotalNumber($nick)
    echo -s 14File :15 $nopath($filename)
    echo -s 14Status : 9Completed
    if ($GetWaitingNumber($nick) == 0) {
      if ($GetActiveNumber($nick) > 0) {
        echo -s 14Still15 $GetActiveNumber($nick) 14in queue 
        echo -s 14Waiting for next in queue 15->
      }
      if ($GetActiveNumber($nick) == 0) {
        echo -s 14AutoLeech on15 $nick 9finished
        unset %AutoLeech_ [ $+ [ $nick ] ]
        if ($nick isin %AutoLeechList) {
          set %AutoLeechList $remtok(%AutoLeechList, $matchtok(%AutoLeechList, $nick, 1, 32), 1, 32)
          if (%AutoLeechList == $null) unset %AutoLeechList
        }
      }
    }
  }
}
on 1:GETFAIL:*:{
  if (%AutoLeech_ [ $+ [ $nick ] ] ) {
    echo -s 15AutoLeech on $nick
    echo -s 14Pack : 15 $+ $calc( 1+ $GetCompletedNumber($nick) ) $+ 14 $+ $chr(47) $+ 15 $+ $GetTotalNumber($nick)
    echo -s 14File : 15 $+ $nopath($filename)
    echo -s 14Status : 4Failed
    echo -s 15Starting again
    MoveFailedtoWaiting $nick
    .timer 1 30 QueueNext $nick
  }
}
on 1:NOTICE:*Denied, You already have * items queued, Try Again Later:?:{
  if (%AutoLeech_ [ $+ [ $nick ] ] ) {
    MovetoWaiting $nick
    .timerAutoLeech_ [ $+ [ $nick ] ] off
  }
}
on 1:NOTICE:*Invalid Pack Number, Try Again:?:{
  if ( (%AutoLeech_ [ $+ [ $nick ] ] ) && ($GetActive($nick) != 0) ) { 
    if ($GetActiveNumber($nick) == 1) {
      SetActive $nick 0
      if (($GetWaitingNumber($nick) == 0) && ($GetCompletedNumber($nick) == 0)) {
        echo -s 14AutoLeech on15 $nick 9finished14. All pack from AutoLeech list removed.
        unset %AutoLeech_ [ $+ [ $nick ] ]
        if ($nick isin %AutoLeechList) {
          set %AutoLeechList $remtok(%AutoLeechList,$matchtok(%AutoLeechList, $nick,1,32),1,32)
          if (%AutoLeechList == $null) {
            unset %AutoLeechList
          }
        }
      }
    }
    else SetActive $nick $deltok( $GetActive($nick), $GetActiveNumber($nick),46)
    echo -s 14Removing invalid pack from15 $nick $+ 14 $+ $chr(39) $+ s AutoLeech list
  }
}
on 1:CONNECT:{
  if (%AutoLeechList) {
    var %j 1
    while (%j <= $numtok(%AutoLeechList,32)) {
      if ($gettok( $gettok(%AutoLeechList, %j, 32),2,44) == $network) {
        .timer 1 10 ResumeAutoLeechXDCC $gettok($gettok(%AutoLeechList, %j,32),1,44))
      }
      inc %j
    }
  }
}
on ^*:NOTICE:*:?:{
  if (%AutoLeechRequestedList_ [ $+ [ $nick ] ]) {
    set -z %AutoLeechRequestedList_ [ $+ [ $nick ] ] 10
    aline 14 @XDCC_list $nick $1-
    halt
  }
}
menu @XDCC_list {
  Download selected: { 
    var %i = 1
    while (%i <= $sline(@XDCC_list,0)) {
      var %nick = $gettok($sline(@XDCC_list,%i),1,32)
      var %num = $strip($remove($gettok( $sline(@XDCC_list,%i), 2, 32),$chr(35),$chr(32)))
      if (%num isnum) {
        if ($istokcs(%@XDCC_list_nick,%nick,32)  == $false) {
          set %@XDCC_list_nick $addtok(%@XDCC_list_nick,%nick,32)
          set %@XDCC_list_added_files_ [ $+ [ %nick ] ]
        }
        if (%AutoLeech_ [ $+ [ %nick ] ]) {
          if (($istok( $GetWaiting(%nick), %num, 46) == $false) && ($istok($GetActive(%nick), %num, 46) == $false) && ($istok($GetCompleted(%nick), %num,46) == $false)) {
            var %temp
            if ($GetWaiting(%nick) != 0) {
              set %temp $GetWaiting(%nick)
              set %temp $addtok( %temp, %num, 46)
            }
            else set %temp %num
            SetWaiting %nick %temp
            cline 15 @XDCC_list $sline(@XDCC_list,%i).ln
            inc %@XDCC_list_added_files_ [ $+ [ %nick ] ]
          }
        }
        else {
          set %AutoLeech_ [ $+ [ %nick ] ] %num
          set %AutoLeech_ [ $+ [ %nick ] ] $addtok( %AutoLeech_ [ $+ [ %nick ] ], 0 $+ $chr(32) $+ 0, 32)
          set %AutoLeechList $addtok(%AutoLeechList, %nick $+ $chr(44) $+ $network, 32)
          cline 15 @XDCC_list $sline(@XDCC_list,%i).ln
          inc %@XDCC_list_added_files_ [ $+ [ %nick ] ]
        }
      }
      inc %i
    }
    if (%@XDCC_list_nick) {
      var %j 1
      while (%j <= $numtok(%@XDCC_list_nick,32)) {
        var %nick = $gettok(%@XDCC_list_nick, %j, 32)
        var %i = %@XDCC_list_added_files_ [ $+ [ %nick ] ]
        if (%i > 0) {
          echo -s 15 $+ %i $iif((%i > 1), 14files, 14file) $+ $chr(32) $+ added in15 %nick $+ 14 $+ $chr(39) $+ s AutoLeech list
          if ($GetWaitingNumber(%nick) == %i) .timerAutoLeech_ [ $+ [ %nick ] ] %i 20 QueueNext %nick
        }
        else echo -s 14No file added in15 %nick $+ 14 $+ $chr(39) $+ s AutoLeech list
        inc %j
      }
    }
    unset %@XDCC_list_*
  }
  Select matching: {
    var %input $$?="Find text :"
    var %i = 1
    while (%i <= $fline(@XDCC_list,$chr(42) $+ %input $+ $chr(42), 0)) {
      if (%i = 1) sline @XDCC_list $fline(@XDCC_list,$chr(42) $+ %input $+ $chr(42), 1)
      else sline -a @XDCC_list $fline(@XDCC_list,$chr(42) $+ %input $+ $chr(42), %i)
      inc %i
    }
  }
  Remove selected: {
    var %i = 1
    while (%i <= $sline(@XDCC_list, 0)) {
      dline @XDCC_list $sline(@XDCC_list, 1).ln
    }
  }
}

Conclusion :


Cet Add-on est en chantier et j'espère pouvoir encore l'améliorer et l'optimiser. Vos remarques/critiques/suggestions sont donc les bienvenues :)

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.