mIRC Homepage

Need help scripting version of mIRC's get dialog!

Posted By: MrZebra

Need help scripting version of mIRC's get dialog! - 24/08/03 08:46 PM

Hi all,

Ok, you know how when you go to mIRC's dcc options, u can select the option to have it pop up the get dialog if the file exists? Then when u get a file, the get dialog pops up and then if u want to, you can accept the file, but rename it, so that if someone sends u file.ext , you can save it as file(1).ext ?

Ok, so how would I go about scripting this? I dont' want to have to be at my computer when the get dialog pops up, but I still want to be able to rename the files. Now, yes , i do know that I could download the file to a temp directory, then rename it after it completes, and move it back to the main directory. But I really wanted to avoid moving files after download. Also, I just want to do what mIRC will do, only automate it.

I've been trying to use ctcp events, but I can't figure out, when you get the dcc send file ip port size, how you are supposed to respond to get the file, or to get the file and rename it.

Any ideas??? I'd be soo appreciative smile
Thanks.

Z
Posted By: codemastr

Re: Need help scripting version of mIRC's get dialog! - 24/08/03 08:48 PM

I don't believe this can be done.
Posted By: theRat

Re: Need help scripting version of mIRC's get dialog! - 24/08/03 09:11 PM

download it to download dir and rename it there?
Posted By: MrZebra

Re: Need help scripting version of mIRC's get dialog! - 24/08/03 09:18 PM

Well...in response to post #1. Yeah I'm beginning to think it is impossible, unfortunately...

In response to post #2. Well I know I could download to temp directory and rename it after...but I wan't to avoid moving the files around and such after download. and I can't download it to the download directory if the file already exists :|..
Thus why I"m trying to find a way, using ctcp's possibly, to just do what mIRC's get dialog will do, rename first and download...
Z
Posted By: demitrix

Re: Need help scripting version of mIRC's get dialog! - 24/08/03 10:20 PM

its not possible to rename the incoming file but u can rename the previous file recieved
Code:
on 1:DCCSERVER:Send:{
  if ($exists($findfile(C:,$1-,1) == $true) {
    var %file = $findfile(C:,$1-,1)
    var %ext = $right(%file,4)
    var %file2 = $remove(%file,%ext) $+ (1) $+ %ext
    rename %file %file2
  }
}
Posted By: Othello

Re: Need help scripting version of mIRC's get dialog! - 24/08/03 10:58 PM

I have a simple script that auto renames a text to the nicks name.txt maybe its somethign you can play around with
now if you are monitoring your downloads you might be able to insert a $$?="Enter New FileName" into the script. Now this
script has not been tested.


on *:FILERCVD:*: {
var %gfile = $nopath($filename)
if ( $exists($+($getdir\,%gfile)) == $true ) {
.rename $filename $+(",$getdir\,$$?="Enter New FileName",")
.remove $+(",$getdir\,%gfile,")
halt
}
}


This is the original script

on *:FILERCVD:*: {
var %setfile = $nopath($filename)
var %getnick = $+($replace($nick,|,!),.txt)
if (( .txt isin %setfile ) && ( $nick isin %setfile )) {
if ( $exists($+(%ldir,%getnick)) == $true ) { .remove $+(",%ldir,%getnick,") }
.rename $filename $+(",%ldir,%getnick,")
halt
}
}

Posted By: MrZebra

Re: Need help scripting version of mIRC's get dialog! - 24/08/03 11:03 PM

"its not possible to rename the incoming file but u can rename the previous file recieved"

well..maybe I phrased that wrong... but mIRC's get dialog can do it. You can choose the option to "save file as" and name it anything you want before the file even starts to download...
which is the basis of what I'm trying to do...

So I was trying to find the ctcp commands to connect to the sender's port and download the file...but as I stated, I'm beginning to think that it's impossible to imitate what mIRC's built in get dialog will do unfortunately...

So I'll probably HAVE to end up dealing with either renaming the exising file, or downloading the new file to a temp dir, renaming it, and moving it to main dir...

*sigh*

Z
Posted By: codemastr

Re: Need help scripting version of mIRC's get dialog! - 24/08/03 11:09 PM

Well you don't send CTCP commands to connect to the sender, mIRC initiates a socket connection. Yes, if you implemented the DCC SEND protocol using a script, then you could do this, but you can't use mIRC's internal DCC SEND/GET handling and change the filename like that.
Posted By: MrZebra

Re: Need help scripting version of mIRC's get dialog! - 24/08/03 11:11 PM

soo....then it is impossible to script something that will just do what mIRC's built in get dialog will do..

and its impossible to in any way manipulate that get dialog so that it would be automated...

ARGH...

Z

p.s. heh, scripting is so frustrating some times
Posted By: codemastr

Re: Need help scripting version of mIRC's get dialog! - 24/08/03 11:27 PM

In theory, you could modify the get dialog using a dll, but it would require a bunch of work in order to figure out how mIRC communicates with that dialog in order to have it send information back to mIRC, for example how does the dialog tell mIRC which filename you entered. It could be done, but it would require a decent amount of programming experience.
Posted By: MrZebra

Re: Need help scripting version of mIRC's get dialog! - 24/08/03 11:35 PM

Yeah...

I am totally unfamiliar with dll's...well...with WRITING them at least...
I can use them..but other than that i'm lost...

DARN IT DARN IT smile

Z
Posted By: Hammer

Re: Need help scripting version of mIRC's get dialog! - 25/08/03 12:18 PM

Code:
ctcp *:DCC SEND*:?:{
  if !$regex($3-,/^(.+) (?!0 )(?:\d+) (?!0 )(?:\d+) (?!0$)(?:\d+)$/) {
    dcc reject
    halt 
  }
  tokenize 32 $regml(1)
  if $isfile($+(", $getdir($1-), $1-, ")) {
    var %e = $mid($1-, $pos($1-, ., $pos($1-, ., 0)))
    .rename $+(", $getdir($1-), $1-, ") $&
      $+(", $getdir($1-), $left($1-, $+(-, $len(%e))), -[, $ctime, ], %e, ")
  }
}


Posted By: MrZebra

Re: Need help scripting version of mIRC's get dialog! - 25/08/03 06:46 PM

Hammer, I'm not familiar with the $regex..but I"m gonna look that stuff up...

As to the second part with the .rename in it, isn't that renaming the file already on the hard drive? Not doing what mIRC's get dialog does, which is rename the incoming file to what you want ??

Thanks for the post, you obviously are much better at scripting than me, but i just wanted to ask these questions.

Z
© 2020 mIRC Discussion Forums