Project

General

Profile

[Script] DCC Download Info & Stats v0.1 » DCC Download Info & Stats v0.1.ini

Mr. BS, 04/23/2016 09:31 PM

 
; DCC Downloads Info & Stats
; http://dev.adiirc.com/boards/5/topics/614
; v0.1 by pereba

alias -l DCCInfoVersion {
return 0.1
}

; Save stats on finish download
On *:FILERCVD:*:{
; Session stats
if (!$hget(DCCInfoSessionStats)) {
hmake DCCInfoSessionStats
}
hinc -m DCCInfoSessionStats DCCSessionStats_Down $get(-1).size
hinc DCCInfoSessionStats DCCSessionStats_Items 1
if ($get(-1).size > $iif($hget(DCCInfoSessionStats,DCCSessionStats_BiggestSize),$v1,0)) {
hadd DCCInfoSessionStats DccSessionStats_BiggestSize $get(-1).size
hadd DCCInfoSessionStats DccSessionStats_BiggestFilename $get(-1).file
}
hinc DCCInfoSessionStats DccSessionStats_AverageSpeed $get(-1).cps
; Perma stats
hinc -m DCCInfo DccPermaStats_Down $get(-1).size
hinc DCCInfo DccPermaStats_Items 1
if ($get(-1).size > $iif($hget(DCCInfo,DCCPermaStats_BiggestSize),$v1,0)) {
hadd DCCInfo DccPermaStats_BiggestSize $get(-1).size
hadd DCCInfo DccPermaStats_BiggestFilename $get(-1).file
}

hinc DCCInfo DccPermaStats_AverageSpeed $get(-1).cps

; Stats since this date
if (!$hget(DCCInfo,DccPermaStats_Since)) {
hadd DCCInfo DccPermaStats_Since $ctime
}
DCCInfoSaveToDisk
}

alias DCCPermaStats {
if ($hget(DCCInfo,DCCPermaStats_Since)) {
; Perma Stats
var %items $hget(DCCInfo,DCCPermaStats_Items), %size $bytes($hget(DCCInfo,DCCPermaStats_Down),g3).suf, %biggest $hget(DCCInfo,DCCPermaStats_BiggestFilename) $bytes($hget(DCCInfo,DCCPermaStats_BiggestSize),g3).suf, %speed $bytes($calc($hget(DCCInfo,DccPermaStats_AverageSpeed) / $hget(DCCInfo,DCCPermaStats_Items)),g3).suf $+ /s, %since $asctime($v1)
describe $active $($hget(DCCInfo,dccPermaStats_ $+ $hget(DCCInfo,Active_theme)),2)
}
}

alias DCCSessionStats {
if ($hget(DCCInfo,DCCPermaStats_Since)) {
; Session Stats
var %items $hget(DCCInfoSessionStats,DCCSessionStats_Items), %size $bytes($hget(DCCInfoSessionStats,DCCSessionStats_Down),g3).suf, %biggest $hget(DCCInfoSessionStats,DCCSessionStats_BiggestFilename) $bytes($hget(DCCInfoSessionStats,DCCvStats_BiggestSize),g3).suf, %speed $bytes($calc($hget(DCCInfoSessionStats,DccSessionStats_AverageSpeed) / $hget(DCCInfoSessionStats,DCCSessionStats_Items)),g3).suf $+ /s, %since $null
describe $active $($hget(DCCInfo,dccSessionStats_ $+ $hget(DCCInfo,Active_theme)),2)
}
}

On *:START: {
var %f = $DCCInfoConfigFile
if ($exists(%f)) {
hload -mi DCCInfo %f
}
else {
hmake DCCInfo
hadd -m DCCInfo Active_theme Default
hadd DCCInfo themes Default
$DCCInfoSave($dccreset(dccstats),$dccreset(dccactive),$dccreset(dccfinished),$dccreset(dccpermastats),$dccreset(dccsessionstats),Default)
hadd DCCInfo themes $addtok($hget(DCCInfo,themes),Plain Text,8203)
$DCCInfoSave($strip($dccreset(dccstats)),$strip($dccreset(dccactive)),$strip($dccreset(dccfinished)),$strip($dccreset(dccpermastats)),$strip($dccreset(dccsessionstats)),Plain_Text)
}
}

alias -l DCCInfoSave {
hadd DCCInfo dccstats_ $+ $6 $1
hadd DCCInfo dccactive_ $+ $6 $2
hadd DCCInfo dccfinished_ $+ $6 $3
hadd DCCInfo dccpermastats_ $+ $6 $4
hadd DCCInfo dccsessionstats_ $+ $6 $5
DCCInfoSaveToDisk
}

alias -l DCCInfoConfigFile {
return $qt($adiircdirDCCInfoConfig.ini)
}

alias -l DCCInfoSaveToDisk {
hsave -i DCCInfo $DCCInfoConfigFile
}

alias DCCconfig {
dialog -mr DCCInfo DCCInfo
}

dialog DCCInfo {
title "DCC Info Edit Themes"
size -1 -1 312 230
option dbu
tab "General", 100, -1 4 314 201
tab "Perma Stats", 101
box "Stats Output ( /dccstats )", 1, 5 19 303 60, tab 100
edit "", 2, 10 30 260 30, multi autovs vsbar tab 100
button "Reset", 3, 272 32 33 12, tab 100
button "Clear Style", 4, 272 46 33 12, tab 100
edit "Variables: % $+ transfers % $+ leech % $+ inactive % $+ downloaded % $+ remaining % $+ totalspeed % $+ ETA", 5, 10 64 260 10, read tab 100
box "Active Downloads ( /dccactive and /dccfind )", 6, 5 81 303 60, tab 100
edit "", 7, 10 92 260 30, multi autovs vsbar tab 100
button "Reset", 8, 272 94 33 12, tab 100
button "Clear Style", 9, 272 109 33 12, tab 100
edit "Variables: % $+ filename % $+ speed % $+ sender % $+ size % $+ remaining % $+ percent % $+ ETA % $+ added", 10, 10 127 260 10, read tab 100
box "Finished Items ( /dccfinished and /dccfind )", 11, 5 143 303 60, tab 100
edit "", 12, 10 154 260 30, multi autovs vsbar tab 100
button "Reset", 13, 272 156 33 12, tab 100
button "Clear Style", 14, 272 170 33 12, tab 100
edit "Variables: % $+ filename % $+ speed % $+ sender % $+ size % $+ added", 15, 10 188 260 10, read tab 100
box "Perma Stats ( /dccpermastats )", 30, 5 19 303 60, tab 101
edit "", 31, 10 30 260 30, multi autovs vsbar tab 101
button "Reset", 32, 272 32 33 12, tab 101
button "Clear Style", 33, 272 46 33 12, tab 101
edit "Variables: % $+ items % $+ speed % $+ size % $+ biggest % $+ since", 34, 10 64 260 10, read tab 101
box "Session Stats ( /dccsessionstats )", 35, 5 81 303 60, tab 101
edit "", 36, 10 92 260 30, multi autovs vsbar tab 101
button "Reset", 37, 272 94 33 12, tab 101
button "Clear Style", 38, 272 109 33 12, tab 101
edit "Variables: % $+ items % $+ speed % $+ size % $+ biggest", 39, 10 127 260 10, read tab 101
button "&Save", 16, 10 210 37 12
button "&Close", 17, 54 210 37 12, cancel
button "&Preview", 18, 98 210 37 12
text "Ps: All fields uses standard", 19, 166 212 109 8
link "scripting syntax.", 20, 230 212 44 8
text "Theme", 21, 180 5 18 8
combo 22, 198 3 80 50, drop
button "+", 23, 280 3 14 11
button "-", 24, 295 3 14 11
}

alias -l loadTheme {
did -ra $1 2 $hget($1,dccstats_ $+ $spacefix($2-))
did -ra $1 7 $hget($1,dccactive_ $+ $spacefix($2-))
did -ra $1 12 $hget($1,dccfinished_ $+ $spacefix($2-))
did -ra $1 31 $hget($1,dccpermastats_ $+ $spacefix($2-))
did -ra $1 36 $hget($1,dccsessionstats_ $+ $spacefix($2-))
}

on *:DIALOG:DCCInfo:*:*:{
if ($devent == init) {
; Themes dropdown
tokenize 8203 $hget(DCCInfo,themes) | did -a $dname 22 $* | did -c $dname 22 1

; Load default theme
loadTheme $dname Default
}
if ($devent == close) {
window -c $+(@,DCC,$chr(160),Info,$chr(160),Preview,$chr(160))
}
if ($devent == sclick) {
; Select theme
if ($did == 22) {
loadTheme $dname $spacefix($did($dname,$did))
}
; New theme button (+)
if ($did == 23) {
var %theme $$?="New Theme Name:"
if ($istok($hget(DCCInfo,themes),%theme,8203)) {
noop $input(Theme named " %theme " already exists $+ $chr(44) try again.,o,New Theme Error)
return
}
hadd -m $dname themes $addtok($hget(DCCInfo,themes),%theme,8203)
$DCCInfoSave($dccreset(dccstats),$dccreset(dccactive),$dccreset(dccfinished),$dccreset(dccpermastats),$dccreset(dccsessionstats),$spacefix(%theme))
; Update dropdown
did -a $dname 22 %theme | did -c $dname 22 $did($dname,22).lines
loadTheme $dname %theme
DCCInfoSaveToDisk
}
; Remove theme button (-)
if ($did == 24) {
if ($did($dname,22) == Default) {
noop $input(Nononono! Default theme can't be removed.,o,Remove Theme Error)
return
}
if (!$input(Are you sure you want to delete the theme named " $did($dname,22) " ?,o,Remove Theme)) {
return
}
var %theme $spacefix($did($dname,22))
hadd -m $dname themes $remtok($hget($dname,themes),$did($dname,22),0,8203)
hdel $dname dccstats_ $+ %theme
hdel $dname dccactive_ $+ %theme
hdel $dname dccfinished_ $+ %theme
hdel $dname dccpermastats_ $+ %theme
hdel $dname dccsessionstats_ $+ %theme
; Restore active theme to Default if deleting the current one
if ($hget($dname,Active_theme) == %theme) {
hadd -m $dname Active_theme Default
}
; Update dropdown
did -d $dname 22 $did(DCCInfo,22).sel | did -c $dname 22 1
did -ra $dname 2 $hget(DCCInfo,dccstats_Default)
did -ra $dname 7 $hget(DCCInfo,dccactive_Default)
did -ra $dname 12 $hget(DCCInfo,dccfinished_Default)
did -ra $dname 12 $hget(DCCInfo,dccpermastats_Default)
did -ra $dname 12 $hget(DCCInfo,dccsessionstats_Default)
DCCInfoSaveToDisk
}

; Reset buttons
if ($did == 3) {
did -ra $dname 2 $dccreset(dccstats)
}
if ($did == 8) {
did -ra $dname 7 $dccreset(dccactive)
}
if ($did == 13) {
did -ra $dname 12 $dccreset(dccfinished)
}
if ($did == 32) {
did -ra $dname 31 $dccreset(dccpermastats)
}
if ($did == 37) {
did -ra $dname 36 $dccreset(dccsessionstats)
}

; Clear Style buttons
if ($did == 4) {
did -ra $dname 2 $strip($did($dname,2))
}
if ($did == 9) {
did -ra $dname 7 $strip($did($dname,7))
}
if ($did == 14) {
did -ra $dname 12 $strip($did($dname,12))
}
if ($did == 33) {
did -ra $dname 31 $strip($did($dname,31))
}
if ($did == 38) {
did -ra $dname 36 $strip($did($dname,36))
}

; Save button
if ($did == 16) {
; Format: dccstats, dccactive, dccfinished, dccpermastats, dccsessionstats, theme name
$DCCInfoSave($did($dname,2),$did($dname,7),$did($dname,12),$did($dname,31),$did($dname,36),$spacefix($did($dname,22)))
did -b $dname $did
did -ra $dname $did Saved $chr(10004)
.timer 1 1 if ( $!dialog(dccinfo) ) did -ra $dname $did &Save $(|) if ( $!dialog(dccinfo) ) did -e $dname $did
}
; Preview button
if ($did == 18) {
dccpreview $spacefix($did(DCCInfo,22))
}

; Scripting syntax link
if ($did == 20) {
url https://dev.adiirc.com/projects/adiirc/wiki/Formatting_text
}
}
}

alias -l spacefix {
return $replacex($1,$chr(32),_)
}

alias -l dccpreview {
var %w $+(@DCC,$chr(160),Info,$chr(160),Preview,$chr(160)), %echo echo -tw2c action %w $replace($prefixemote,$!pnick,$me,$!status,@,$!nick,$me), %echo2 echo -c info %w, %blank echo %w $chr(160), %transfers $rand(1,99), %leech $rand(1,%transfers), %inactive $calc(%transfers - %leech), %downloaded $bytes($rand(10000,999999999999),g3).suf, %remaining $bytes($rand(10000,999999999999),g3).suf, %totalspeed $bytes($rand(10000,99999999),g3).suf $+ /s, %ETA $duration($rand(1,$calc(60*60*6))), %added $duration($rand(360,$calc(360*60)))

if (!$window(%w)) {
window -dCkw0 $+ $iif($readini($adiircini,n,Messages,UseNickColumn),q1) %w -1 -1 1024 430
}
else {
clear %w | window -a %w
}
%echo2 ───────────█ Preview Theme $1 █───────────
%blank
%echo2 --==[ /dccstats ]==--
%echo $($hget(DCCInfo,dccstats_ $+ $1),2)
%blank
var %filename AdiIRC_ $+ $rand(1,9999) $+ .zip, %speed $bytes($rand(10000,99999999),g3).suf $+ /s, %sender adiirc.com
%echo2 --==[ /dccactive and /dccfind ]==--
%echo $($hget(DCCInfo,dccactive_ $+ $1),2)
%blank
%filename = AdiIRC_ $+ $rand(1,9999) $+ .zip
%speed = $bytes($rand(10000,99999999),g3).suf $+ /s
%echo2 --==[ /dccfinished and /dccfind ]==--
%echo $($hget(DCCInfo,dccfinished_ $+ $1),2)
%blank
var %items $rand(1,999), %size %downloaded, %biggest AdiIRC_pack.zip %remaining, %speed %totalspeed, %since who knows
%echo2 --==[ /dccpermastats ]==--
%echo $($hget(DCCInfo,dccpermastats_ $+ $1),2)
%blank
%echo2 --==[ /dccsessiontats ]==--
%echo $($hget(DCCInfo,dccsessionstats_ $+ $1),2)
}

alias -l dccreset {
if ($1 == dccstats) return 7[DCC] 15Transfers:14 % $+ transfers 15(3Leeching:14 % $+ leech $!+ ,4 Finished:14 % $+ inactive $!+ 15) Downloaded:14 % $+ downloaded 15Remaining:14 % $+ remaining 15Total Speed:14 % $+ totalspeed 15ETA:14 % $+ ETA 
if ($1 == dccactive) return 3is leeching14 % $+ filename 15@14 % $+ speed 15from14 % $+ sender 15finishing in14 % $+ ETA 
if ($1 == dccfinished) return 3Downloaded14 % $+ filename 15@14 % $+ speed 15from14 % $+ sender 
if ($1 == dccpermastats) return 14⿻ 7[DCC All Time Stats]14 ⿻ 15Completed Files:14 % $+ items 15Total Downloaded:14 % $+ size 15Biggest File:14 % $+ biggest 15Average Speed:14 % $+ speed 15Since:14 % $+ since ⿻
if ($1 == dccsessionstats) return 14⿻ 7[DCC This Session Stats]14 ⿻ 15Completed Files:14 % $+ items 15Total Downloaded:14 % $+ size 15Biggest File:14 % $+ biggest 15Average Speed:14 % $+ speed ⿻
}

alias dccactive {
$dccfind(*).active
}

alias dccfinished {
$dccfind(*).finished
}

alias dccrun {
$dccfind($1-).run
}

alias dccfind {
if (!$1) {
tokenize 32 $$?="Enter Search String (willdcard supported)"
}
if (!$get(0)) {
echo -taguc info >>> No dcc gets in progress. <<<
return
}

var %i = 1, %inactive 0, %speed 0, %downbytes 0, %ETA_total 0, %remaining 0, %sender, %filename, %size, %percent, %added
while (%i <= $get(0)) {

if ($1- isin $get(%i).file || $1- iswm $get(%i).file) {
; Speed count
%speed = $bytes($get(%i).cps,g3).suf $+ /s

; ETA
var %ETA = $duration($calc(($get(%i).size - $get(%i).rcvd) / $get(%i).cps))

; Remaining
;inc %remaining $calc($get(%i).size - $get(%i).rcvd)
%remaining = $bytes($calc($get(%i).size - $get(%i).rcvd),g3).suf

; Bytes downloaded
if ($get(%i).status != failed) inc %downbytes $get(%i).rcvd

; Inactive count
if ($get(%i).done || $get(%i).status) inc %inactive

; Sender
%sender = $get(%i)

; Filename
%filename = $get(%i).file
; Size
%size = $bytes($get(%i).size,g3).suf
; Percentage
%percent = $get(%i).pc $+ %
; Added
%added = $duration($get(%i).secs)

; Active downloads output
if (!$get(%i).done && !$get(%i).status && $prop != finished) {
describe $active $($hget(DCCInfo,dccactive_ $+ $hget(DCCInfo,Active_theme)),2)
}
; Inactive output
elseif ($prop != active && $get(%i).done) {
if ($prop == run) {
run $qt($get(%i).path $+ \ $+ $get(%i).file)
}
else {
describe $active $($hget(DCCInfo,dccfinished_ $+ $hget(DCCInfo,Active_theme)),2)
}
}
}

inc %i
}
}

alias dccstats {
if (!$get(0)) {
echo -taguc info >>> No dcc gets in progress. <<<
return
}

var %i = 1
var %inactive 0, %speed 0, %downbytes 0, %ETA 0, %remaining 0
while (%i <= $get(0)) {

if (!$get(%i).status) {
; Speed count
inc %speed $get(%i).cps

; ETA
inc %ETA $calc(($get(%i).size - $get(%i).rcvd) / $get(%i).cps)

; Remaining
inc %remaining $calc($get(%i).size - $get(%i).rcvd)
}

; Bytes downloaded
if ($get(%i).status != failed) inc %downbytes $get(%i).rcvd

; Inactive count
if ($get(%i).done || $get(%i).status) inc %inactive
inc %i
}

var %totalspeed $bytes(%speed,g3).suf $+ /s
var %transfers $calc($get(0) + $send(0))
var %leech $calc($get(0) - %inactive)
var %downloaded $bytes(%downbytes,g3).suf
%remaining = $bytes(%remaining,g3).suf
%ETA = $duration(%ETA)

describe $active $($hget(DCCInfo,dccstats_ $+ $hget(DCCInfo,Active_theme)),2)
}

alias -l dcchelp {
var %e echo -agtc info
%e Commands -=- DCC Info Help
%e /dcchelp -=- Shows this help
%e /dccstats -=- Shows overall DCC stats
%e /dccactive -=- Shows active downloads
%e /dccfinished -=- Shows finished downloads
%e /dccfind $+ $chr(160) $+ string -=- Shows DCC transfers containing the string
%e /dccrun $+ $chr(160) $+ string -=- Opens DCC transfer finished containing the string
%e /dccconfig -=- Opens DCC Info Edit Themes dialog
%e /dccpermastats -=- Shows session and all time finished downloads stats
}

alias -l setTheme {
hadd -m DCCInfo Active_theme $spacefix($$1-)
DCCInfoSaveToDisk
}

alias -l themesMenu {
var %x $gettok($hget(DCCInfo,themes),$1,8203)
if ($istok(begin end,$1,32)) return -
else return $iif($spacefix(%x) == $hget(DCCInfo,Active_theme), $style(1)) %x :/setTheme %x
}

alias DCCi {
describe $active is using DCC Download Info & Stats v $+ $DCCInfoVersion $+ . Download latest version at http://dev.adiirc.com/boards/5/topics/614
}

menu channel,query {
DCC Info
.Theme
..Edit themes:/DCCconfig
..-
..$submenu($themesMenu($1))
.-
.Stats
..Transfers $chr(9) /dccstats:/dccstats
..All time stats $chr(9) /dccpermastats:/dccpermastats
..This Session stats $chr(9) /dccsessionstats:/dccsessionstats
.-
.Finished items $chr(9) /dccfinished:/dccfinished
.Active downloads $chr(9) /dccactive:/dccactive
.Find $chr(9) /dccfind:/dccfind
.Run $chr(9) /dccrun:/dccrun
.-
.Help $chr(9) /dcchelp:/dcchelp
.-
.About
..$style(2) Version $DCCInfoVersion by Pereba:/
..$style(2) Beta tester Jaglag:/
..-
..Advertise $chr(9) (/DCCi):/DCCi
..-
..Forum link:run http://dev.adiirc.com/boards/5/topics/614
-
}
(4-4/4)