mIRC Home    About    Download    Register    News    Help

Print Thread
#164882 18/11/06 01:18 PM
Joined: Nov 2006
Posts: 15
K
kaosAD Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Nov 2006
Posts: 15
Hi,

How do I write an instruction to automatically resume CTCP whenever a dialog pops up requesting user to click resume, overwrite or ignore because a file already exists?

#164883 18/11/06 02:15 PM
Joined: Nov 2006
Posts: 15
K
kaosAD Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Nov 2006
Posts: 15
Is it something like

on *:DIALOG: ??

But how do I proceed to instruct resuming?

#164884 18/11/06 08:15 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Its built into mirc already.

Tools/options/dcc/ select radiobutton "autoget file" | select dropdown "If file exists" and set to "resume"

#164885 18/11/06 10:18 PM
Joined: Nov 2006
Posts: 15
K
kaosAD Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Nov 2006
Posts: 15
Yes, but I only want to auto resume some files only (files of my choice). Is there a short script which I can use? I have been looking at a number of remote events but there is too less documentation on how to use them.

p/s: I have successfully coded a not-very-well-written script that can recognize events generated by the file I was getting. To make my script better, I would like the auto-resume feature.

#164886 19/11/06 02:42 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Provide the script you've got, no matter how badly you think it's written, and we'll be happy to clue you into (or show you) what modifications are necessary and/or recommended.

#164887 19/11/06 01:26 PM
Joined: Nov 2006
Posts: 15
K
kaosAD Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Nov 2006
Posts: 15
Thank you for your encouragement.

I just picked up programming the script in a day, so I apologize in advance the horrible look of it. I tried this script out my passion to learn and nothing more. The purpose of the script is to automatically get files from a remote server. It requires a text file containing a list of commands to trigger file transfers. The text should contain /ctcp <name> <category> <filename>. The remote server runs a fully working script written by someone else.

Here is my script:

;The following should be in the Aliases:
/getFile {
if ($len(%AG_filename) > 0) {
%AG_pathFile = $getdir $+ %AG_filename

if (%AG_lineNo < line(%AG_pathFile)) {
/echo %AG_lineNo : %AG_pathFile
%AG_command = $read -l %AG_lineNo %AG_pathFile
/echo %AG_pathFile
}
else {
return /echo AG: finish downloading file(s)
}
}
else {
return /echo error: please specify an input file [note: type /setfile]
}

if ($len(%AG_command) > 0) {
/echo excuting %AG_command
return %AG_command
}
else {
return /echo there is no command
}
}

/doCheckFile {
if ($len(%AG_command) > 0) {
%AG_sender = $gettok(%AG_command, 2, 32)
%AG_fileToGet = $gettok(%AG_command, 4, 32)

if (($len(%AG_fileToGet) > 0) && ($len(%AG_sender) > 0)) {
/echo the nick is $1
/echo the file is $2
/echo %AG_sender
/echo %AG_fileToGet
if (($1 == %AG_sender) && ($2 == %AG_fileToGet)) {
/echo AG: getting the next file
/timer 1 10 $getFile
}
}
}
else {
/echo error: internal error in AutoGet script
}
}

/get $getFile()
/setFile %AG_filename = $?="Enter file name" | $reset
/reset %AG_lineNo = 1
/checkFile $doCheckFile($1, $2)

;The following should be in the Remote:
1:FILERCVD:*.*:{%AG_lineNo = %AG_lineNo + 1 | /checkFile $nick $nopath($filename)}
on 1:GETFAIL:*.*:{/checkFile $nick $nopath($filename)}

I want to add a feature to auto-resume when file already exists without manually configuring it in the DCC options.

#164888 19/11/06 08:07 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
* i didnt try to understand what your doing in your code, but i spotted this line if (%AG_lineNo < line(%AG_pathFile)) { i would expect line() is ment to be $line()

* I suggest you group all your script into ONE remote file, you can make your aliases wotrk fromt he remote file by adding the "alias" directive to the front of each alias
ex /doCheckFile { becomes alias /doCheckFile { and moves to the remotes file.

Quote:
I want to add a feature to auto-resume when file already exists without manually configuring it in the DCC options.

That wont be easy, i suggest instead you set the auto resume feature to ON, but then intercept and either delete the old existing file, or redirect the download to a new folder, or rename the old file.

The code you hook in on to get control before the download starts is CTCP ^*:DCC SEND *:{ }

here is a skeleton for working with...
Code:
CTCP ^*:DCC SEND *:{
  ; # correct $1- to deal with files with spaces in #
  tokenize 62 $1 $+ &gt; $+ $2 $+ &gt; $+ $nopath($filename) $+ &gt; $+ $gettok($1-,-3,32) $+ &gt; $+ $gettok($1-,-2,32) $+ &gt; $+ $gettok($1-,-1,32)
 
  ; # $1- = Dcc Send Filename LongIP Port Filesize
  ; $3 contains the filename even if there are spaces in it, $filename conatins the file path/name
 
  ; you can do anything here , check if the file exists, delete/move/rename it etc, before the mirc defualt action of resume if exists takes over.
  ; aka if u renamed the existing one, then a new one well be downloaded.
  ; or redirect the download to a new folder using /dcc get &lt;folder&gt;
}

#164889 20/11/06 01:24 PM
Joined: Nov 2006
Posts: 15
K
kaosAD Offline OP
Pikka bird
OP Offline
Pikka bird
K
Joined: Nov 2006
Posts: 15
Thank you for your suggestion. I will play around with it smile


Link Copied to Clipboard