Script that can allow "uploading"

Which hub software is the best? Where can I find script XXX? Discuss it here...(no, this is not for advertising your hub...)

Moderator: Moderators

Locked
zolakk
Posts: 3
Joined: 2003-03-30 22:05

Script that can allow "uploading"

Post by zolakk » 2003-03-30 22:09

I run a small private hub for my friends, and I wanted to see if it was possible to have them be able to upload to my server as well. I know upload is not built in to DC(++), but I got to thinking, would it be possible to setup a bot that can take a trigger that will then download the file from the user (thus "uploading"). I don't mind writing this myself, but I don't know where to start, or if something like this already exists. Can anyone help me?

ButterflySoul
Posts: 210
Joined: 2003-01-23 17:24
Location: Nevada
Contact:

Post by ButterflySoul » 2003-03-30 22:47

Yes, it's possible, but you don't have the functions/methods directly built in the DC hub software... So you can make a bot react to a trigger, and open a socket, and start the download... But you'll have to make your script handle everything down to the socket level and simulate the dialog that a client would have with your friend's clients; you can't just call a built-in curUser.DownloadFile method, for example =)

If you're looking to gain socket access from your script, you'll need to call a dll of some kind, and use the functions of said dll.
The easiest to play with that I found so far is the oswinsck.dll from OstroSoft. It's freeware, and super easy to work with. I'm not sure what other scripters would suggest, but that's the one I use myself when I need to play with sockets =)

If you want to have a look, the url is http://www.ostrosoft.com/oswinsck.asp
[CoZ] Children of Zeus
-----
Shadows DC Hub - VBS and JS scripting at their best

ButterflySoul
Posts: 210
Joined: 2003-01-23 17:24
Location: Nevada
Contact:

Post by ButterflySoul » 2003-03-31 00:20

By the way, if it's not an absolute neccesity that your script handles the whole download and knows how much each user uploaded to you (i.e. if you're fine with a solution where the script triggers the download, but doesn't have any control on it afterwards) you could "cheat" by letting DC++ run, and having your script edit the Queue.xml file on your local system (skip the first 2 lines, add the info for a new download, save and close. Done)

Working with the sockets is ok for little files, but for larger files, you might want to include some kind resuming if the connection gets cut; and then probably also a rollback after a resume, etc etc etc and you'll soon end up with a large headache =p. Depending on what kind of files your friends will upload, it will save you a lot of coding nights to let DC++ handle the download itself, and use your script only as a trigger =)
[CoZ] Children of Zeus
-----
Shadows DC Hub - VBS and JS scripting at their best

zolakk
Posts: 3
Joined: 2003-03-30 22:05

Post by zolakk » 2003-03-31 00:34

That's more of what I was looking to do... I don't really care what kind of files or how many (I trust my friends, and it's a private hub). All I really need to do is set it up so that each user's "uploads" get placed in a different (home) directory for them, optionally specifying a different path within their directory (i.e. call "upload "c:\blah\foo.txt" "testdir\foo.txt" with user x would upload foo.txt to d:\users\x\testdir\foo.txt for example). I imagine this would be more or less straight forward to to by manipulating the Queue.xml directly, as I have a copy of DC++ running to let them download my stuff anyway.

Paul_Don
Posts: 146
Joined: 2003-01-29 06:41
Location: uk
Contact:

Post by Paul_Don » 2003-04-01 01:34

butterfly u never cease to amaze me with your answers :P

Paul_Don
Posts: 146
Joined: 2003-01-29 06:41
Location: uk
Contact:

Post by Paul_Don » 2003-04-01 01:34

now how bout writing one :D

DamionNH
Posts: 25
Joined: 2003-01-07 11:05

Post by DamionNH » 2003-04-01 13:01

One little problem using the queue.xml file. I think you would have to restart dc++ to read/see the changes.
Owner of Lurkers Lair a Phoenix Rising Hub

ButterflySoul
Posts: 210
Joined: 2003-01-23 17:24
Location: Nevada
Contact:

Post by ButterflySoul » 2003-04-01 15:03

One little problem using the queue.xml file. I think you would have to restart dc++ to read/see the changes.


Even if you do, it's no big deal. You can't append directly to the middle of a file with vbs. You have to either restart it from scratch, either add to it, but from the end.
So when you build the new queue.xml, you'll have to make it read the old line by line, then write a new temporary one, write the 2 top ones of the old file, write a new line for the download you want to add, and finally write the rest of the file behind. From there you copy the temp one over the existing one (the .CopyFile method of the file system object overwrites by default) and you'll have to delete the temporary one.

Instead of deleting it directly from your script, you can keep Word or Access or anything VBA enabled running in the background with a short VBA code looping and checking every 5 minutes if the temporary file exists. If it does, have the VBA code delete the file, and use a sendkeys to throw an Alt-F4 at DC++ (and restart it).
I guess it would be cleaner with a lill custom VB application that came right out of a real Visual Basic editor, but VBA can do the job ok, and most everyone has (part of) ms office somewhere; which is not true for a Visual Basic editor and compiler =)
[CoZ] Children of Zeus
-----
Shadows DC Hub - VBS and JS scripting at their best

zolakk
Posts: 3
Joined: 2003-03-30 22:05

Post by zolakk » 2003-04-01 18:02

I have had a few ideas about doing this, but I am still working on it. In favor of keeping past queues, I have elected to scan the whole file, up until the second to last line, append the new data, then write in the last line and save. I did also notice that DC++ does not automatically check to see if the queue file has changed myself, and am trying to figure out a better way around that as well - I do have and am very good in standard VB, so if I figure this thing out, i'll keep you guys updated.

Thanks for the help so far

ButterflySoul
Posts: 210
Joined: 2003-01-23 17:24
Location: Nevada
Contact:

Post by ButterflySoul » 2003-04-02 21:10

Actually, via the Windows Script Host, you can call (among other things) the native Windows Shell. I've never had any need for it so far, so I didn't think about it right away, but if you :

Code: Select all

Dim Shell
Set Shell = CreateObject("WScript.Shell")
you end up with a nice Shell object which has an AppActivate, a SendKeys and a Run method =p
[CoZ] Children of Zeus
-----
Shadows DC Hub - VBS and JS scripting at their best

Locked