fetching maps - 29/04/07 04:20 AM
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?
;;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:{ }
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 } } }
;;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 } } }
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.* }