XDCC Autoresume/Autoqueue Stealth Script — File Browser

XDCCAutoresumeAutoqueueStealthScriptv4.2.0 / XDCCAutoresumeAutoqueueStealthScriptv4.2.0 / xdccmorebots.mrc

xdccmorebots.mrc — 18.44 KB — Download this file


;-------------------------------------------------------------------------
alias alternatebotsfile { return $preventdoubleslash($xdccdir $+ \ $+ $replxdccfile(%alternatebotsfile)) }
alias specalternatebotsfile { return $replace($getpfffilenm($1, $2),.pff,.aq) }
;-------------------------------------------------------------------------


;-------------------------------------------------------------------------
; /trynextsource $1 $2:
; $1: network.
; $2: nick.
; GENERAL OUTLINE OF MULTISOURCE:
; If a bot is offline and multi source is on and a .aq file exists, 
; this will search for a matching pack on all other bots. 
; If it finds such a pack, it will add it 
; to a list of alternates, for the original bot / pack. It will queue the 
; pack on the first bot if it is online on the same network as you. If 
; not, it will move on to the next bot. Put the activated bot 
; nick and original bot's .aq filename in a single activemultisource file. 
; On raw 401, try the next entry in the accompanying .aq file. 
; If the queue is full or no connections should be made, use this as well. 
; While the other bot is sending, disable the original bot. 
; Maybe make a separate option to use this when starting a pack. 
; Remove entries in .aq file when pack complete, and aq file when queue 
; complete or file empty.
; so: find sources > add to .aq > if original offline > process entry 1 in
; .aq > move from .aq to .aqt ("tried this bot") add to general alternates 
; file and remove from .aq > if bot offline or has active queue or such 
; > try next .aq entry for this pack > if success > remove all entries 
; from .aq and general alternatesfile > if failed all > rename .aqt to .aq
;
; TO DO:
; -Upon completion, check all bots in the appropriate .aq file and dequeue
;  the pack listed in there for them.
; -Upon second get fail, try next source.
;-------------------------------------------------------------------------
alias trynextsource {
  if (%multisourcehandling == on && $triggerHash.exists($1, $2)) {
    set %nextsource $null
    set %sourcesfile $null
    set %botnick $null
    set %packnum $null

    ; determine the sources file
    if ($exists($alternatebotsfile) && $read($alternatebotsfile,wnt,* $2 *) && $exists($gettok($read($alternatebotsfile,wnt,* $2 *),3,32)) && $lines($gettok($read($alternatebotsfile,wnt,* $2 *),3,32))) > 0) {
      /outputxdccinfo 10 $+ $2 has alternate sources (1): $read($gettok($read($alternatebotsfile,wnt,* $2 *),3,32), nt, 1) $+ .
      set %sourcesfile $gettok($read($alternatebotsfile,wnt,* $2 *),3,32)
      /write -dw"* $+ $2 %sourcesfile $+ *" $alternatebotsfile
    }
    elseif ($exists($specalternatebotsfile($1,$2)) && $lines($specalternatebotsfile($1,$2)) > 0) {
      /outputxdccinfo 10 $+ $2 has alternate sources (2): $read($specalternatebotsfile($1,$2), nt, 1) $+ .
      set %sourcesfile $specalternatebotsfile($1,$2)
    }
    elseif ($exists($replace($specalternatebotsfile($1,$2),.aq,.aqt))) {
      /outputxdccinfo 4 $+ $2 has alternate sources, but all sources failed10.
      if ($exists($specalternatebotsfile($1,$2))) { .remove $specalternatebotsfile($1,$2) }
      .rename $replace($specalternatebotsfile($1,$2),.aq,.aqt) $specalternatebotsfile($1,$2)
      if (!$read($xdccsinprogress, snt, $2) && $exists($getqfilenm($1,$2)) && $lines($getqfilenm($1,$2)) > 0) { /write -a $xdccsinprogress $2 $read($getqfilenm($1,$2),nt,1) }
      if ($shouldstartmaxbotq == TRUE && %botqueuehandling == on && $botqueue.exists == TRUE) {
        /outputxdccinfo 14Re-Adding7 $2 14to active transfers file for autoresume and moving to next bot in Bot Queue.
        /startbotqueues 1 
      }
    }

    /debuglog TRYNEXTSOURCE: Sourcesfile is %sourcesfile 
    ; determine the next source and move it to the "tried" file. should build a while loop that stops once a bot without active sends has been found.
    if (%sourcesfile != $null) {
      if ($exists($replace(%sourcesfile,.aq,.aqt)) && $lines($replace(%sourcesfile,.aq,.aqt)) > 0) { set %matchpack $gettok($read($replace(%sourcesfile,.aq,.aqt), nt, $lines($replace(%sourcesfile,.aq,.aqt))),4-,32) }
      elseif ($lines(%sourcesfile) > 0) { set %matchpack $gettok($read(%sourcesfile,nt,1),4-,32) }

      if ($read($xdccsinprogress,snt,$2)) { /write -ds" $+ $2 $+ " $xdccsinprogress }

      ;      remove the appropriate pack from bot $2's queue here.
      if ($exists($getqfilenm($1,$2)) && $read($getqfilenm($1,$2),nt,$gettok($read($replace(%sourcesfile,.aq,.aqt), wnt,* $2 *),3,32))) { /write -dw"* $+ $gettok($read($replace(%sourcesfile,.aq,.aqt), wnt,* $2 *),3,32) $+ *" $getqfilenm($1,$2) }
      if ($lines($getqfilenm($1,$2)) < 1) { .remove $getqfilenm($1,$2) }

      ;     NOTE: i hope matchpack is well determined, or this won't work.

      /debuglog TRYNEXTSOURCE: Matchpack is %matchpack
      if (%matchpack != $null) {
        set %i 1
        while (%i <= $lines(%sourcesfile)) {
          /debuglog TRYNEXTSOURCE: $gettok($read(%sourcesfile,nt,%i),4,32) ==? %matchpack
          if ($gettok($read(%sourcesfile,nt,%i),4,32) == %matchpack) {
            set %nextsource $read(%sourcesfile, nt, %i)
            set %botnick $gettok(%nextsource,2,32)
            set %botnetwork $gettok(%nextsource,1,32)
            set %packnum $gettok(%nextsource,3,32)
            if (%nextsource != $null && !$read($xdccsinprogress,snt,%botnick) && !$read($networkfile(%botnetwork),wnt,* %botnick *)) {
              set %trigger $null
              /debuglog TRYNEXTSOURCE: Nextsource is %nextsource , botnetwork %botnetwork botnick %botnick packnum %packnum

              ;     First write to general alternate source file, then start queue.
              /write -a $alternatebotsfile %botnetwork %botnick %sourcesfile

              ;     Start next source here! Don't use startqueue, but write the whole thing with timers.
              ;     Don't forget to add to $xdccinprogress.
              ;     Finally, remove from specific alternate sources file and add to tried alternates file.


              if ($triggerHash.getTrigger(%botnetwork,%botnick) != $null) { set %trigger $triggerHash.getTrigger(%botnetwork,%botnick) $+ %packnum }

              if (%trigger != $null) {
                /debuglog TRYNEXTSOURCE: Trigger is %trigger
                set %rand.bt $rand(%minresumedelay ,%maxresumedelay)

                set %j 0
                set %con $null
                while (%con == $null && %j < 1000) {
                  if ($scon(%j).network == %botnetwork) { set %con %j }
                  inc %j
                }

                if ($exists($dccallownetworkfile) && $read($dccallownetworkfile,wnt,%botnetwork)) { /scon %con /DCCALLOW + $+ %botnick }
                if ($exists($alternatedccserverfile) && $read($alternatedccserverfile,snt,%botnetwork %botnick)) { $read($alternatedccserverfile,snt,%botnetwork %botnick) }

                ;     write to queue file in position 1, because otherwise the wrong queue item may be removed on completing pack.
                if ($read($getqfilenm(%botnetwork,%botnick),wnt,%packnum)) { /write -dw" $+ %packnum $+ " $getqfilenm(%botnetwork,%botnick) }
                /write -i1 $getqfilenm(%botnetwork,%botnick) %packnum


                /outputxdccinfo Bot7 $2 4is not available. 3Requesting pack from alternate XDCC server in %rand.bt seconds (14 $+ %trigger $+ ). 
                if ($gettok(%trigger, 1, 32) == /msg) { /scon %con /timerxdccautoresume $+ %botnick $+ 1 1 %rand.bt /msg $gettok(%trigger, 2-, 32) }
                elseif ($gettok(%trigger, 1, 32) == /ctcp) { /scon %con /timerxdccautoresume $+ %botnick $+ 1 1 %rand.bt /ctcp $gettok(%trigger, 2-, 32) }
                elseif ($gettok(%trigger, 1, 32) == /notice) { /scon %con /timerxdccautoresume $+ %botnick $+ 1 1 %rand.bt /notice $gettok(%trigger, 2-, 32) }
                else { /outputxdccinfo 4ERROR: unknown trigger type ( $+ %trigger $+ ) }

                /outputxdccinfo 14Disabling group2 autoxdccresume for7 $2 for $calc(%resumedelay + %rand.bt) seconds to prevent repetitive request.
                .timer -o 1 $calc(%resumedelay + %rand.bt) /write -dw" $+ $2 $+ ¦ $+ $1 $+ " $autoresumedisablefile
                if (!$read($autoresumedisablefile, wnt, $2 $+ ¦ $+ $1)) {
                  /write -a $autoresumedisablefile %$2 $+ ¦ $+ $1
                }
                .timer -o 1 $calc(%resumedelay + %rand.bt + 1) /outputxdccinfo 2Autoresume14 reenabled for3 $1 $+ 7 $2 $+ .
                .timer -o 1 $calc(%resumedelay + %rand.bt + 1) /outputxdccinfo 

                /write -a $xdccsinprogress %botnick %packnum
              }

              /write -a $replace(%sourcesfile,.aq,.aqt) $read(%sourcesfile, wnt,%botnetwork %botnick * %matchpack)
              /write -dw" $+ %botnetwork %botnick $+ * $+ %matchpack $+ " %sourcesfile
              set %i $lines(%sourcesfile)
            }
            elseif (%botnick != $null && ($read($xdccsinprogress,snt,%botnick) || $read($networkfile($1),wnt,* %botnick *))) {
              /outputxdccinfo 14Cannot start alternate source:7 %botnick 14on3 %botnetwork 14already has a send or request in progress.
              /write -a $replace(%sourcesfile,.aq,.aqt) $read(%sourcesfile, wnt,* %botnick *)
              /write -dw"* $+ %botnick $+ *" %sourcesfile
              dec %i
            }
          }
          inc %i
        }
      }
      else { /outputxdccinfo 14MULTISOURCE: 4ERROR: Matchpack is NULL. }
    }
    elseif ($exists($replace($specalternatebotsfile($1,$2),.aq,.aqt))) { /outputxdccinfo 4Bot is not reachable and has no alternate sources left14 (3 $+ $1 $+ 14¦7 $+ $2 $+ 14). }
    else { 
      /outputxdccinfo 4Bot is not reachable and has no alternate sources listed14 (3 $+ $1 $+ 14¦7 $+ $2 $+ 14). 
      if ($shouldstartmaxbotq == TRUE && %botqueuehandling == on && $botqueue.exists == TRUE) { 
        /outputxdccinfo 14Moving to next bot in Bot Queue.
        /startbotqueues 1 
      }
    }
    /outputxdccinfo 
  }
  elseif ($shouldstartmaxbotq == TRUE && %botqueuehandling == on && $botqueue.exists == TRUE) { 
    /outputxdccinfo Bot7 $2 4is not available. Moving to next bot in Bot Queue.
    /startbotqueues 1 
    /outputxdccinfo 
  }
}
;-------------------------------------------------------------------------
;-------------------------------------------------------------------------



;[22:41:33] Alternate source file found for [peewee]XDCC04. Dequeueing all alternate sources packs.
;[22:41:33] Dequeue: No such packnumber queued for irchighway¦dutchie35 (1).  < cd1
;[22:41:33] Dequeue: No such packnumber queued for irchighway¦[SICK]XDCC28 (3). < cd1
;[22:41:33] Dequeue: No such packnumber queued for irchighway¦dutchie35 (2). < cd2
;[22:41:33] Dequeue: No such packnumber queued for irchighway¦[SICK]XDCC28 (4). < cd2 Wildcard match to broad?
;-------------------------------------------------------------------------
; Add this to BOTH the filereceiveds in xdccscript.mrc.
; Should still remove entries in .aqt files and improve removal for .aq 
; and general alternate bots file.
;-------------------------------------------------------------------------
on *:FILERCVD:*:{
  set %sourcesfile $null
  if ($exists($alternatebotsfile) && $read($alternatebotsfile,wnt,$network $nick *) && $exists($gettok($read($alternatebotsfile,wnt,$network $nick *),3,32))) { set %sourcesfile $gettok($read($alternatebotsfile,wnt,$network $nick *),3,32) }
  elseif ($exists($specalternatebotsfile($network,$nick)) && $lines($specalternatebotsfile($network,$nick)) > 0) { set %sourcesfile $specalternatebotsfile($network,$nick) }
  if (%sourcesfile != $null) {
    /outputxdccinfo Alternate source file found for7 $nick $+ . 6Dequeueing all alternate sources packs.
    set %i 1
    set %matchpack $gettok($read(%sourcesfile, wnt,$network $nick *),4-,32)
    while (%i <= $lines(%sourcesfile)) {
      if (* $+ %matchpack iswm $read(%sourcesfile, nt, %i)) { 
        /write -dw" $+ $gettok($read(%sourcesfile, nt, %i),1-2,32) %sourcesfile $+ " $alternatebotsfile      
        /removefromq $gettok($read(%sourcesfile, nt, %i),2,32) $gettok($read(%sourcesfile, nt, %i),1,32) $gettok($read(%sourcesfile, nt, %i),3,32)
        /write -dl $+ %i %sourcesfile 
        dec %i
      }
      inc %i
    }
    set %i 1
    set %sourcesfile $replace(%sourcesfile,.aq,.aqt)
    while (%i <= $lines(%sourcesfile)) {
      if (* $+ %matchpack iswm $read(%sourcesfile, nt, %i)) { 
        /write -dw" $+ $gettok($read(%sourcesfile, nt, %i),1-2,32) %sourcesfile $+ " $alternatebotsfile
        /removefromq $gettok($read(%sourcesfile, nt, %i),2,32) $gettok($read(%sourcesfile, nt, %i),1,32) $gettok($read(%sourcesfile, nt, %i),3,32)
        /write -dl $+ %i %sourcesfile 
        dec %i
      }
      inc %i
    }
    /write -dw" $+ $network $nick %sourcesfile $+ " $alternatebotsfile
    if ($lines($alternatebotsfile) == 0) { .remove $alternatebotsfile }
    if ($lines($replace(%sourcesfile,.aqt,.aq)) == 0) { .remove $replace(%sourcesfile,.aqt,.aq) }
    if ($lines(%sourcesfile) == 0) { .remove %sourcesfile }

    /outputxdccinfo 
  }
}
;-------------------------------------------------------------------------
;-------------------------------------------------------------------------






;-------------------------------------------------------------------------
alias replallpackdesc { return $replace($1-,_,*,$chr(58),*,$chr(59),*,+,*,!,*,@,*,^,*,~,*,`,*,¦,*,€,*,=,*,$chr(32),*,.,*,gets,*,size,*,description,*,bytes,*,byte,*,$chr(40),*,$chr(41),*,[,*,],*,$chr(123),*,$chr(125),*,<,*,>,*,/,*,\,*,&,*,$,*,$chr(44),*,^,*,•,*,«,*,»,*,›,*,‹,*,-,*,s0,*,s1,*1,s2,*2,s3,*3,s4,*4,s5,*5,s6,*6,s7,*7,s8,*8,s9,*9,x0,*0,x1,*1,x2,*2,x3,*3,x4,*4,x5,*5,x6,*6,x7,*7,x8,*8,x9,*9,e0,*0,e1,*1,e2,*2,e3,*3,e4,*4,e5,*5,e6,*6,e7,*7,e8,*8,e9,*9,***,*,**,*) }
alias replmatchpackattempt { 
  set %numtok $calc($numtok($1-,32) - 1)
  set %packdescript $null
  set %i 1
  while (%i <= %numtok) {
    if ($remove($strip($gettok($1-,%i,32),burc),+,!,?,¿,-,@,~,',`,",$,%,^,€,&,|,¦,$chr(44),=,$chr(123),$chr(125),$chr(58),$chr(59),.,•,«,»,›,‹,[,],<,>,*,$chr(35),$chr(32),$chr(40),$chr(41),_,/,\,1,2,3,4,5,6,7,8,9,0,b,k,m,g,t,x,$chr(47),$chr(92)) != $null) { set %packdescript $strip(%packdescript $gettok($1-,%i,32),burc) }
    inc %i
  }
  return $replallpackdesc($remvextentnodot(%packdescript))
}
;-------------------------------------------------------------------------


;-------------------------------------------------------------------------
; $1: The original bot's network.
; $2: The original bot's nickname.
; $3: Pack number.
;-------------------------------------------------------------------------
alias checkformorepacksources {
  if ($read($getpfffilenm($1,$2),snt,$3)) {
    set %pack $remove($read($getpfffilenm($1,$2),snt,$3),$triggerHash.getChan($1,$2),$2,$1)
    set %packdescript $replmatchpackattempt(%pack)
    /checkformoresources $1 $2 %packdescript
  }
  else { 
    /outputxdccinfo 14No such pack. 
    /outputxdccinfo 
  }
}
;-------------------------------------------------------------------------
;-------------------------------------------------------------------------


;-------------------------------------------------------------------------
; /checkformoresources $1 $2 $3-:
; $1: The original bot's network.
; $2: The original bot's nickname.
; $3-: The pack currently queued.
; This checks if a pack is available on more sources and adds those 
; sources to the bot's .aq file.
;-------------------------------------------------------------------------
alias checkformoresources {
  /outputxdccinfo 10Searching for more sources for13 $3- $+ ... (This can cause nonresponsiveness in your IRC for a number of seconds depending on the size of your library, please hold)...
  set %searchpack $remvallnonum($nopath($3-))
  set %i 1
  set %sourcescount 0
  while (%i <= $triggerHash.items) {
    set %j 1 
    while (%j <= $lines($getpfffilenm($triggerHash.item.network(%i),$triggerHash.item.nick(%i)))) {
      set %matchpack $remvallnonum($read($getpfffilenm($triggerHash.item.network(%i),$triggerHash.item.nick(%i)),nt,%j))
      ;/debuglog CHECKMORESOURCES: %j $getpfffilenm($triggerHash.item.network(%i),$triggerHash.item.nick(%i)) $+ : %searchpack ==? %matchpack
      if (* $+ %searchpack $+ * iswm %matchpack && !$read($specalternatebotsfile($1, $2),wnt,$triggerHash.item.network(%i) $triggerHash.item.nick(%i) * $3-) && !$read($replace($specalternatebotsfile($1, $2),.aq,.aqt),wnt,$triggerHash.item.network(%i) $triggerHash.item.nick(%i) * $3-) && ($triggerHash.item.network(%i) $triggerHash.item.nick(%i) != $1 $2)) {
        inc %sourcescount
        /write -a $specalternatebotsfile($1, $2) $triggerHash.item.network(%i) $triggerHash.item.nick(%i) $gettok($read($getpfffilenm($triggerHash.item.network(%i),$triggerHash.item.nick(%i)),nt,%j),1,32) %searchpack 
        /outputxdccinfo Adding3 $triggerHash.item.network(%i) 7 $+ $triggerHash.item.nick(%i) as alternate source for14 $3-.
      }
      inc %j
    }
    inc %i
  }
  /outputxdccinfo 10Found %sourcescount NEW alternate sources for13 $3- $+  (Note: the packfinder may not find all sources possible).
  /outputxdccinfo 
}
;-------------------------------------------------------------------------
;-------------------------------------------------------------------------

;-------------------------------------------------------------------------
; $1: original network
; $2: original bot
; $3: original packnr
; $4: alternate source network
; $5: alternate source bot
; $6: alternate source packnr
;-------------------------------------------------------------------------
alias manualaddmoresources { 
  if (!$read($specalternatebotsfile($1, $2),wnt,$4 $5 $6 $replmatchpackattempt($read($getpfffilenm($1, $2),snt, $3))) && !$read($replace($specalternatebotsfile($1, $2),.aq,.aqt),wnt,$4 $5 $6 $replmatchpackattempt($read($getpfffilenm($1, $2),snt, $3)))) { 
    /outputxdccinfo 14Adding3 $4 $+ 7 $5 $+ 13 $6 $replmatchpackattempt($read($getpfffilenm($1, $2),snt, $3)) 14as an alternate source for3 $1 $+ 14¦7 $+ $2 $+ 14.
    /write -a $specalternatebotsfile($1, $2) $4 $5 $6 $replmatchpackattempt($read($getpfffilenm($1, $2),snt, $3)) 
    /outputxdccinfo 
  }
  else {
    /outputxdccinfo 14That source is already listed as an alternate. 
    /outputxdccinfo 
  }
}
;-------------------------------------------------------------------------
;-------------------------------------------------------------------------