mIRC Home    About    Download    Register    News    Help

Print Thread
#175819 29/04/07 04:20 AM
Joined: Feb 2007
Posts: 33
H
harl91 Offline OP
Ameglian cow
OP Offline
Ameglian cow
H
Joined: Feb 2007
Posts: 33
is there a way to on the text "harlbot fetch (html address here no brackets)" that harlbot will go to the webpage and get the file, and put it into the folder i want?

harl91 #175820 29/04/07 04:50 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Yes, read up on the following sections in the help file

ON TEXT
Sockets

RusselB #175821 29/04/07 05:06 AM
Joined: Feb 2007
Posts: 33
H
harl91 Offline OP
Ameglian cow
OP Offline
Ameglian cow
H
Joined: Feb 2007
Posts: 33
i dont quite understand sockets, i was hoping someone could point me in the right direction

harl91 #175829 29/04/07 01:13 PM
Joined: Dec 2002
Posts: 580
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580

Last edited by NaquadaServ; 29/04/07 01:15 PM.

NaquadaBomb
www.mirc-dll.com
Joined: Feb 2007
Posts: 33
H
harl91 Offline OP
Ameglian cow
OP Offline
Ameglian cow
H
Joined: Feb 2007
Posts: 33
Code:
;;Fetch Maps

on *:text:*fetch*:*:{
  if ($1 == $me) {
    set %map.address $3
    set %map.name %4-
    set %.map $right( %map.name , 4)
    if (%.map !== .map) { set %map.name %map.name $+ .map }
    if ($exists(c:/winbolo/maps/ $+ %map.name ) == $true ) { msg $chan I already have that map. | goto havemap }
    sockopen fetch %map.address 80
    :havemap
  }
}

on *:sockopen:fetch:{
  if ($sockerr) return
  sockwrite -n $sockname GET / HTTP/1.1
  sockwrite -n $sockname Host: %map.address
  sockwrite -n $sockname Accept: */*
  sockwrite -n $sockname Connection: Close
  sockwrite -n $sockname
}

on *:sockread:fetch:{

}


thats what i got so far. I was wondering if someone can get it so that on sockread it downloads the file and puts it into c:/winbolo/maps/

harl91 #176139 04/05/07 06:48 AM
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Maybe this will do the job for you
Code:
on *:sockread:fetch:{
  ; check if the header has been recieved
  ; if so read the data to a binvar and bwrite it
  if $sock($sockname).mark {
    sockread -f &a
    bwrite $+(c:/winbolo/maps/,%map.name) -1 -1 &a
  }

  ; Otherwise, read the header data and do nothing with it
  else {
    var %a | sockread %a
    ; The header will be followed by a blank line
    ; If the var is empty the header has been recieved
    if !%a { sockmark $sockname 1 }
  }
}

P.S. In the on text event, you should check if you are already downloading a map before trying to get another. You can do that by setting a var and unset it again in a sockclose event or by checking if $sock(fetch) is $null (or you could use multiple sockets).


deegee #176153 04/05/07 03:46 PM
Joined: Feb 2007
Posts: 33
H
harl91 Offline OP
Ameglian cow
OP Offline
Ameglian cow
H
Joined: Feb 2007
Posts: 33
There is no need to see if there is another download because the map files take about 2 seconds to download.

Now I've edited it abit, and it deosn't seem to work...
Can someone help me out? I dont see whats wrong with it...

Code:
;;Fetch Maps

on *:text:*fetch*:*:{
  if ($1 == $me) {
    set %map.address $3
    set %map.name $4-
    set %.map $right( %map.name , 4)
    if (%.map !== .map) { set %map.name %map.name $+ .map }
    if ($exists(c:/winbolo/maps/ $+ %map.name ) == $true ) { msg $chan I already have that map. | goto havemap }
    sockopen fetch %map.address 80
    :havemap
  }
}

on *:sockopen:fetch:{
  if ($sockerr) return
  sockwrite -n $sockname GET / HTTP/1.1
  sockwrite -n $sockname Host: %map.address
  sockwrite -n $sockname Accept: */*
  sockwrite -n $sockname Connection: Close
  sockwrite -n $sockname
  msg $chan Downloading %map.name ....
}

on *:sockread:fetch:{
  ; check if the header has been recieved
  ; if so read the data to a binvar and bwrite it
  if $sock( $sockname ).mark {
    sockread -f &a
    bwrite c:/winbolo/maps/ $+ %map.name -1 -1 &a
    msg $chan Download Complete!
  }
  ; Otherwise, read the header data and do nothing with it
  else {
    var %a | sockread %a
    ; The header will be followed by a blank line
    ; If the var is empty the header has been recieved
    if !%a { sockmark $sockname 1 }
  }
}


P.S. Thanks deegee for your help.

Last edited by harl91; 04/05/07 05:56 PM.
harl91 #176169 04/05/07 10:59 PM
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Quote:
There is no need to see if there is another download because the map files take about 2 seconds to download.

Even 1 second is more than enough time for another request to mess with your %map.* vars possibly causing a wrongly named file and socket error messages.

Try this...
Code:
on *:text:$($me fetch * *):#:{
  var %f = $4- $+ $iif(*.map !iswm $4-,.map)
  if ($file(c:/winbolo/maps/ $+ %f)) { msg # I already have that map. | return }
  if ($sock(fetch)) { msg # Socket busy, try again. | return }
  set -e %map.address $remove($3,http://)
  set -e %map.name %f
  set -e %map.chan #
  sockopen fetch $gettok(%map.address,1,47) 80
}
on *:sockopen:fetch:{
  if ($sockerr) return
  sockwrite -n $sockname GET / $+ $gettok(%map.address,2-,47) HTTP/1.1
  sockwrite -n $sockname Host: $sock($sockname).addr
  sockwrite -n $sockname Connection: Close
  sockwrite -n $sockname
  msg %map.chan Downloading %map.name ....
}
on *:sockread:fetch:{
  ; check if the header has been recieved
  ; if so read the data to a binvar and bwrite it
  if ($sock($sockname).mark) {
    sockread -f &a
    bwrite $qt(c:/winbolo/maps/ $+ %map.name) -1 -1 &a
  }
  ; Otherwise, read the header data and do nothing with it
  else {
    var %a | sockread %a
    ; The header will be followed by a blank line
    ; If the var is empty the header has been recieved
    if (!%a) { sockmark $sockname 1 }
  }
}
on *:sockclose:fetch:{
  msg %map.chan Download of %map.name $iif($file(c:/winbolo/maps/ $+ %map.name),Complete!,Failed!)
  unset %map.*
}

deegee #176174 04/05/07 11:37 PM
Joined: Feb 2007
Posts: 33
H
harl91 Offline OP
Ameglian cow
OP Offline
Ameglian cow
H
Joined: Feb 2007
Posts: 33
hmm, for some reason it didn't work to start, but then i switched the map to download, and BOOM it works. I tested it on some otheres and it works just fine! Thanks for all your help.


Link Copied to Clipboard