:dcc stats formatting
:module
:
alias fixmeter {
	if (isdigit($0)) {
                if ([$0] < 7)                   { return $(c4)°°°°°°°°°°°°$(cl) }
		if (([$0] < 14) && ([$0] >= 7)) { return $(c4)°°°°°°°°°°°°$(cl) }                                                                             
		if (([$0] < 21) && ([$0] >= 14)) { return $(c4)$(bblk)$(c2)°$(c4)°°°°°°°°°°°$(cl) }
		if (([$0] < 28) && ([$0] >= 21)) { return $(c4)$(bblk)$(c2)°°$(c4)°°°°°°°°°°$(cl) }
		if (([$0] < 35) && ([$0] >= 28)) { return $(c4)$(bblk)$(c2)°°±$(c4)°°°°°°°°°$(cl) }
		if (([$0] < 42) && ([$0] >= 35)) { return $(c4)$(bblk)$(c2)°°±±$(c4)°°°°°°°°$(cl) }
		if (([$0] < 49) && ([$0] >= 42)) { return $(c4)$(bblk)$(c2)°°±±²$(c4)°°°°°°°$(cl) }
		if (([$0] < 56) && ([$0] >= 49)) { return $(c4)$(bblk)$(c2)°°±±²²$(c4)°°°°°°$(cl) }
		if (([$0] < 63) && ([$0] >= 56)) { return $(c4)$(bblk)$(c2)°°±±²²Û$(c4)°°°°°$(cl) }
		if (([$0] < 70) && ([$0] >= 63)) { return $(c4)$(bblk)$(c2)°°±±²²ÛÛ$(c4)°°°°$(cl) }
		if (([$0] < 77) && ([$0] >= 70)) { return $(c4)$(bblk)$(c2)°°±±²²ÛÛ$(c1)±$(c4)°°°$(cl) }
		if (([$0] < 84) && ([$0] >= 77)) { return $(c4)$(bblk)$(c2)°°±±²²ÛÛ$(c1)±±$(c4)°°$(cl) }
		if (([$0] < 91) && ([$0] >= 84)) { return $(c4)$(bblk)$(c2)°°±±²²ÛÛ$(c1)±±Û$(c4)°$(cl) }
                if ([$0] >= 91)                  { return $(c4)$(bblk)$(c2)°°±±²²ÛÛ$(c1)±±ÛÛ$(cl) }
	}
        ^restub fixmeter dcc.m
}	
on ^dcc_header * {    
	echo $fparse(format_header dcc stats)
	echo $fparse(format_midbar $(c4)[$(c2)num$(c4)][$(c2)type$(c4)][$(c2)nick      $(c4)][$(c2)status$(c4)][$(c2)completed   $(c4)][$(c2)kps  $(c4)][$(c2)file                 $(c4)])
}
on ^dcc_stat * {
	echo $fparse(format_midbar $(c4)[$(c3)$[-3]0$(c4)][$(c3)$[4]tolower($1)$(c4)][$(c3)$[10]2$(c4)][$(c3)$[6]3$(c4)][$(c3)$[11] $(c4)][$(c3)$[5]4$(c4)][$(c3)$[21]5$(c4)])
}
on ^dcc_statf * {  
        @dnum = [$0] 
        @dtyp = [$1]   
        @dnic = [$2]
        @dsta = [$3]
        @dkps = [$4]
	@dfil = [$5]
}
on ^dcc_statf1 * {  
        @dper = [$left(5 $0)] 
        @dsen = [$1]   
        @dtot = [$2]
        @dmin = [$3]
        @dsec = [$4]
	if (strlen($dsec) == [1]) { @dsec = [0] ## [$dsec] }
        echo $fparse(format_midbar $(c4)[$(c3)$[-3]dnum$(c4)][$(c3)$[4]tolower($dtyp)$(c4)][$(c3)$[10]dnic$(c4)][$(c3)$[6]dsta$(c4)][$(c3)$fixmeter($dper)$(c4)][$(c3)$[5]dkps$(c4)][$(c3)$[21]dfil$(c4)]) 
	echo $fparse(format_midbar                        $(c4)[$(c3)$([-3]dmin):$(dsec)$(c4)][$(c3)$[-12]fix.size($dsen)$(c4)][$(c3)$sar(/ //$[5](dper))%$(c4)][$(c3)$[21]fix.size($dtot)$(c4)])                             
}
on ^dcc_post * {
	echo $fparse(format_footer dcc stats)
}
on -dcc_request "*" {
        @_dnic = [$0]
        if ([$1] == [GET]) {
		if ([$dcc_autoget] = [on] && [$auto_resume] == [on] && fexist($twiddle($(dcc_dldir)/$2)) && fsize($twiddle($(dcc_dldir)/$2)) < [$3]) {
			^toggle dcc_autoget
			timer -ref 124 -rep 1 .1 { 
				/dcc resume $_dnic 
				xecho -b auto resuming file from $(c4)[$(c2)$_dnic$(c4)]
				^dcc_autoget = [on]
			}
		}
		{
		        timer -ref 123 -rep 1 .1 { xecho -b press $(c4)[$(c2)ctrl-A$(c4)]$(c3) to accept the file or $(c4)[$(c2)ctrl-R$(c4)]$(c3) to reject it. }
		}
	}
}
alias dcc_get {
	/dcc get $_dnic
	^restub dcc_get dcc.m
}
alias dcc_rej {
	/dcc close get $_dnic
	^restub dcc_rej dcc.m
}
on ^dcc_transfer_stat "*" { 
	echo $fparse(format_header transfer stats)
	echo $fparse(format_midbar $(c4)[$(c2)inbound       $(c4)][$(c2)outbound      $(c4)][$(c2)status    $(c4)][$(c2)toggles                     $(c4)])
	echo $fparse(format_midbar $(c4)[$(c3)total:$[-8](fix.size(0))$(c4)][$(c3)total:$[-8](fix.size($3))$(c4)][$(c3) total:$[-3]6$(c4)][$(c3)autoget:$[-4]tolower($9)$(c4)][$(c3)overwrite:$[-4]tolower($12)$(c4)])
	echo $fparse(format_midbar $(c4)[$(c3)  max:$[-5](1)kps$(c4)][$(c3)  max:$[-5](4)kps$(c4)][$(c3)active:$[-3]7$(c4)][$(c3)  quiet:$[-4]tolower($10)$(c4)][$(c3)    paths:$[-4]tolower($11)$(c4)])
	echo $fparse(format_midbar $(c4)[$(c3)  min:$[-5](2)kps$(c4)][$(c3)  min:$[-5](5)kps$(c4)][$(c3) limit:$[-3]8$(c4)])
	echo $fparse(format_footer transfer stats)
}
