Download – Dosya indirici addon
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
Örnek : /download Sohbet.net selam.txt İşte kod: alias download { if ($sock(download)) { echo $colour(info text) @download *** başka bir dosya download ediliyor, birazdan tekrar deneyiniz. return } sockopen download $1 80 sockmark download $1 $2 } on *:sockopen:download:{ if ($sockerr) { echo $colour(info text) @download *** download ederken hata: $sockerr return } write -c $gettok($sock($sockname).mark,2,32) unset %downloadlength %downloadready window -c @download sockwrite -n $sockname GET $+(/,$gettok($sock($sockname).mark,2,32)) HTTP/1.0 sockwrite -n $sockname Accept: */* sockwrite -n $sockname Host: $gettok($sock($sockname).mark,1,32) sockwrite -n $sockname } on *:sockread:download:{ if (%downloadready != 1) { var %header sockread %header while ($sockbr) { if (Content-length: * iswm %header) { %downloadlength = $gettok(%header,2,32) if (* !iswm $window(@download)) window @download echo $colour(info text) @download *** dosya boyutu: %downloadlength bytes } elseif (* !iswm %header) { %downloadready = 1 %downloadoffset = $sock($sockname).rcvd break } sockread %header } } sockread 4096 &d while ($sockbr) { if (* !iswm $window(@download)) window @download echo $colour(info text) @download *** alınan: $round( $calc(100 * ($sock($sockname).rcvd - %downloadoffset) / %downloadlength) ,1) $+ % bwrite $gettok($sock($sockname).mark,2,32) -1 -1 &d sockread 4096 &d } } on *:sockclose:download:{ echo $colour(info text) @download *** indirme tamamlandı. } |