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

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

    
5
alias -l DCCInfoVersion {
6
  return 0.1
7
}
8

    
9
; Save stats on finish download
10
On *:FILERCVD:*:{
11
  ; Session stats
12
  if (!$hget(DCCInfoSessionStats)) {
13
    hmake DCCInfoSessionStats
14
  }
15
  hinc -m DCCInfoSessionStats DCCSessionStats_Down $get(-1).size
16
  hinc DCCInfoSessionStats DCCSessionStats_Items 1
17
  if ($get(-1).size > $iif($hget(DCCInfoSessionStats,DCCSessionStats_BiggestSize),$v1,0)) {
18
    hadd DCCInfoSessionStats DccSessionStats_BiggestSize $get(-1).size
19
    hadd DCCInfoSessionStats DccSessionStats_BiggestFilename $get(-1).file
20
  }
21
  hinc DCCInfoSessionStats DccSessionStats_AverageSpeed $get(-1).cps
22
  
23
  ; Perma stats
24
  hinc -m DCCInfo DccPermaStats_Down $get(-1).size
25
  hinc DCCInfo DccPermaStats_Items 1
26
  if ($get(-1).size > $iif($hget(DCCInfo,DCCPermaStats_BiggestSize),$v1,0)) {
27
    hadd DCCInfo DccPermaStats_BiggestSize $get(-1).size
28
    hadd DCCInfo DccPermaStats_BiggestFilename $get(-1).file
29
  }
30

    
31
  hinc DCCInfo DccPermaStats_AverageSpeed $get(-1).cps
32

    
33
  ; Stats since this date
34
  if (!$hget(DCCInfo,DccPermaStats_Since)) {
35
    hadd DCCInfo DccPermaStats_Since $ctime
36
  }
37
  
38
  DCCInfoSaveToDisk
39
}
40

    
41
alias DCCPermaStats {
42
  if ($hget(DCCInfo,DCCPermaStats_Since)) {
43
    ; Perma Stats  
44
    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)
45
    describe $active $($hget(DCCInfo,dccPermaStats_ $+ $hget(DCCInfo,Active_theme)),2)
46
  }
47
}
48

    
49
alias DCCSessionStats {
50
  if ($hget(DCCInfo,DCCPermaStats_Since)) {
51
    ; Session Stats
52
    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
53
    describe $active $($hget(DCCInfo,dccSessionStats_ $+ $hget(DCCInfo,Active_theme)),2)
54
  }
55
}
56

    
57
On *:START: {
58
  var %f = $DCCInfoConfigFile
59
  if ($exists(%f)) {
60
    hload -mi DCCInfo %f
61
  }
62
  else {
63
    hmake DCCInfo
64
    hadd -m DCCInfo Active_theme Default
65
    hadd DCCInfo themes Default
66
    $DCCInfoSave($dccreset(dccstats),$dccreset(dccactive),$dccreset(dccfinished),$dccreset(dccpermastats),$dccreset(dccsessionstats),Default)
67
    
68
    hadd DCCInfo themes $addtok($hget(DCCInfo,themes),Plain Text,8203)
69
    $DCCInfoSave($strip($dccreset(dccstats)),$strip($dccreset(dccactive)),$strip($dccreset(dccfinished)),$strip($dccreset(dccpermastats)),$strip($dccreset(dccsessionstats)),Plain_Text)
70
  }
71
}
72

    
73
alias -l DCCInfoSave {
74
  hadd DCCInfo dccstats_ $+ $6 $1
75
  hadd DCCInfo dccactive_ $+ $6 $2
76
  hadd DCCInfo dccfinished_ $+ $6 $3
77
  hadd DCCInfo dccpermastats_ $+ $6 $4
78
  hadd DCCInfo dccsessionstats_ $+ $6 $5
79
  DCCInfoSaveToDisk
80
}
81

    
82
alias -l DCCInfoConfigFile {
83
  return $qt($adiircdirDCCInfoConfig.ini)
84
}
85

    
86
alias -l DCCInfoSaveToDisk {
87
  hsave -i DCCInfo $DCCInfoConfigFile
88
}
89

    
90
alias DCCconfig {
91
  dialog -mr DCCInfo DCCInfo
92
}
93

    
94
dialog DCCInfo {
95
  title "DCC Info Edit Themes"
96
  size -1 -1 312 230
97
  option dbu
98
  
99
  tab "General", 100, -1 4 314 201
100
  tab "Perma Stats", 101
101
  
102
  box "Stats Output ( /dccstats )", 1, 5 19 303 60, tab 100
103
  edit "", 2, 10 30 260 30, multi autovs vsbar tab 100
104
  button "Reset", 3, 272 32 33 12, tab 100
105
  button "Clear Style", 4, 272 46 33 12, tab 100
106
  edit "Variables: % $+ transfers % $+ leech % $+ inactive % $+ downloaded % $+ remaining % $+ totalspeed % $+ ETA", 5, 10 64 260 10, read tab 100
107
  
108
  box "Active Downloads ( /dccactive and /dccfind )", 6, 5 81 303 60, tab 100
109
  edit "", 7, 10 92 260 30, multi autovs vsbar tab 100
110
  button "Reset", 8, 272 94 33 12, tab 100
111
  button "Clear Style", 9, 272 109 33 12, tab 100
112
  edit "Variables: % $+ filename % $+ speed % $+ sender % $+ size % $+ remaining % $+ percent % $+ ETA % $+ added", 10, 10 127 260 10, read tab 100
113
  
114
  box "Finished Items ( /dccfinished and /dccfind )", 11, 5 143 303 60, tab 100
115
  edit "", 12, 10 154 260 30, multi autovs vsbar tab 100
116
  button "Reset", 13, 272 156 33 12, tab 100
117
  button "Clear Style", 14, 272 170 33 12, tab 100
118
  edit "Variables: % $+ filename % $+ speed % $+ sender % $+ size % $+ added", 15, 10 188 260 10, read tab 100
119
  
120
  box "Perma Stats ( /dccpermastats )", 30, 5 19 303 60, tab 101
121
  edit "", 31, 10 30 260 30, multi autovs vsbar tab 101
122
  button "Reset", 32, 272 32 33 12, tab 101
123
  button "Clear Style", 33, 272 46 33 12, tab 101
124
  edit "Variables: % $+ items % $+ speed % $+ size % $+ biggest % $+ since", 34, 10 64 260 10, read tab 101
125
  
126
  box "Session Stats ( /dccsessionstats )", 35, 5 81 303 60, tab 101
127
  edit "", 36, 10 92 260 30, multi autovs vsbar tab 101
128
  button "Reset", 37, 272 94 33 12, tab 101
129
  button "Clear Style", 38, 272 109 33 12, tab 101
130
  edit "Variables: % $+ items % $+ speed % $+ size % $+ biggest", 39, 10 127 260 10, read tab 101
131
  
132
  button "&Save", 16, 10 210 37 12
133
  button "&Close", 17, 54 210 37 12, cancel
134
  button "&Preview", 18, 98 210 37 12
135
  
136
  text "Ps: All fields uses standard", 19, 166 212 109 8
137
  link "scripting syntax.", 20, 230 212 44 8
138
  
139
  text "Theme", 21, 180 5 18 8
140
  combo 22, 198 3 80 50, drop
141
  button "+", 23, 280 3 14 11
142
  button "-", 24, 295 3 14 11
143
}
144

    
145
alias -l loadTheme {
146
  did -ra $1 2 $hget($1,dccstats_ $+ $spacefix($2-))
147
  did -ra $1 7 $hget($1,dccactive_ $+ $spacefix($2-))
148
  did -ra $1 12 $hget($1,dccfinished_ $+ $spacefix($2-))
149
  did -ra $1 31 $hget($1,dccpermastats_ $+ $spacefix($2-))
150
  did -ra $1 36 $hget($1,dccsessionstats_ $+ $spacefix($2-))
151
}
152

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

    
158
    ; Load default theme
159
    loadTheme $dname Default
160
  }
161
  
162
  if ($devent == close) {
163
    window -c $+(@,DCC,$chr(160),Info,$chr(160),Preview,$chr(160))
164
  }
165
  
166
  if ($devent == sclick) {
167
    ; Select theme
168
    if ($did == 22) {
169
      loadTheme $dname $spacefix($did($dname,$did))
170
    }
171
    
172
    ; New theme button (+)
173
    if ($did == 23) {
174
      var %theme $$?="New Theme Name:"
175
      if ($istok($hget(DCCInfo,themes),%theme,8203)) {
176
        noop $input(Theme named " %theme " already exists $+ $chr(44) try again.,o,New Theme Error)
177
        return
178
      }
179
      hadd -m $dname themes $addtok($hget(DCCInfo,themes),%theme,8203)
180
      $DCCInfoSave($dccreset(dccstats),$dccreset(dccactive),$dccreset(dccfinished),$dccreset(dccpermastats),$dccreset(dccsessionstats),$spacefix(%theme))
181
      
182
      ; Update dropdown
183
      did -a $dname 22 %theme | did -c $dname 22 $did($dname,22).lines
184
      
185
      loadTheme $dname %theme
186
      
187
      DCCInfoSaveToDisk
188
    }
189
    
190
    ; Remove theme button (-)
191
    if ($did == 24) {
192
      if ($did($dname,22) == Default) {
193
        noop $input(Nononono! Default theme can't be removed.,o,Remove Theme Error)
194
        return
195
      }
196
      if (!$input(Are you sure you want to delete the theme named " $did($dname,22) " ?,o,Remove Theme)) {
197
        return
198
      }
199
      var %theme $spacefix($did($dname,22))
200
      hadd -m $dname themes $remtok($hget($dname,themes),$did($dname,22),0,8203)
201
      hdel $dname dccstats_ $+ %theme
202
      hdel $dname dccactive_ $+ %theme
203
      hdel $dname dccfinished_ $+ %theme
204
      hdel $dname dccpermastats_ $+ %theme
205
      hdel $dname dccsessionstats_ $+ %theme
206
      
207
      ; Restore active theme to Default if deleting the current one
208
      if ($hget($dname,Active_theme) == %theme) {
209
        hadd -m $dname Active_theme Default
210
      }
211
      
212
      ; Update dropdown
213
      did -d $dname 22 $did(DCCInfo,22).sel | did -c $dname 22 1
214
      did -ra $dname 2 $hget(DCCInfo,dccstats_Default)
215
      did -ra $dname 7 $hget(DCCInfo,dccactive_Default)
216
      did -ra $dname 12 $hget(DCCInfo,dccfinished_Default)
217
      did -ra $dname 12 $hget(DCCInfo,dccpermastats_Default)
218
      did -ra $dname 12 $hget(DCCInfo,dccsessionstats_Default)
219
      
220
      DCCInfoSaveToDisk
221
    }
222

    
223
    ; Reset buttons
224
    if ($did == 3) {
225
      did -ra $dname 2 $dccreset(dccstats)
226
    }
227
    if ($did == 8) {
228
      did -ra $dname 7 $dccreset(dccactive)
229
    }
230
    if ($did == 13) {
231
      did -ra $dname 12 $dccreset(dccfinished)
232
    }
233
    if ($did == 32) {
234
      did -ra $dname 31 $dccreset(dccpermastats)
235
    }
236
    if ($did == 37) {
237
      did -ra $dname 36 $dccreset(dccsessionstats)
238
    }
239

    
240
    ; Clear Style buttons
241
    if ($did == 4) {
242
      did -ra $dname 2 $strip($did($dname,2))
243
    }
244
    if ($did == 9) {
245
      did -ra $dname 7 $strip($did($dname,7))
246
    }
247
    if ($did == 14) {
248
      did -ra $dname 12 $strip($did($dname,12))
249
    }
250
    if ($did == 33) {
251
      did -ra $dname 31 $strip($did($dname,31))
252
    }
253
    if ($did == 38) {
254
      did -ra $dname 36 $strip($did($dname,36))
255
    }
256

    
257
    ; Save button
258
    if ($did == 16) {
259
      ; Format: dccstats, dccactive, dccfinished, dccpermastats, dccsessionstats, theme name
260
      $DCCInfoSave($did($dname,2),$did($dname,7),$did($dname,12),$did($dname,31),$did($dname,36),$spacefix($did($dname,22)))
261
      did -b $dname $did
262
      did -ra $dname $did Saved $chr(10004)
263
      .timer 1 1 if ( $!dialog(dccinfo) ) did -ra $dname $did &Save $(|) if ( $!dialog(dccinfo) ) did -e $dname $did
264
    }
265
    
266
    ; Preview button
267
    if ($did == 18) {
268
      dccpreview $spacefix($did(DCCInfo,22))
269
    }
270

    
271
    ; Scripting syntax link
272
    if ($did == 20) {
273
      url https://dev.adiirc.com/projects/adiirc/wiki/Formatting_text
274
    }
275
  }
276
}
277

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

    
282
alias -l dccpreview {
283
  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)))
284

    
285
  if (!$window(%w)) {
286
    window -dCkw0 $+ $iif($readini($adiircini,n,Messages,UseNickColumn),q1) %w -1 -1 1024 430
287
  }
288
  else {
289
    clear %w | window -a %w
290
  }
291
  
292
  %echo2 ───────────█ Preview Theme $1 █───────────
293
  
294
  %blank
295
  
296
  %echo2 --==[ /dccstats ]==--
297
  %echo $($hget(DCCInfo,dccstats_ $+ $1),2)
298
  
299
  %blank
300
  
301
  var %filename AdiIRC_ $+ $rand(1,9999) $+ .zip, %speed $bytes($rand(10000,99999999),g3).suf $+ /s, %sender adiirc.com
302
  %echo2 --==[ /dccactive and /dccfind ]==--
303
  %echo $($hget(DCCInfo,dccactive_ $+ $1),2)
304
  
305
  %blank
306
  
307
  %filename = AdiIRC_ $+ $rand(1,9999) $+ .zip
308
  %speed = $bytes($rand(10000,99999999),g3).suf $+ /s
309
  %echo2 --==[ /dccfinished and /dccfind ]==--
310
  %echo $($hget(DCCInfo,dccfinished_ $+ $1),2)
311
  
312
  %blank
313
  
314
  var %items $rand(1,999), %size %downloaded, %biggest AdiIRC_pack.zip %remaining, %speed %totalspeed, %since who knows
315
  %echo2 --==[ /dccpermastats ]==--
316
  %echo $($hget(DCCInfo,dccpermastats_ $+ $1),2)
317
  
318
  %blank
319
  
320
  %echo2 --==[ /dccsessiontats ]==--
321
  %echo $($hget(DCCInfo,dccsessionstats_ $+ $1),2)
322
}
323

    
324
alias -l dccreset {
325
  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 
326
  if ($1 == dccactive) return 3is leeching14 % $+ filename 15@14 % $+ speed 15from14 % $+ sender 15finishing in14 % $+ ETA 
327
  if ($1 == dccfinished) return 3Downloaded14 % $+ filename 15@14 % $+ speed 15from14 % $+ sender 
328
  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 ⿻
329
  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 ⿻
330
}
331

    
332
alias dccactive {
333
  $dccfind(*).active
334
}
335

    
336
alias dccfinished {
337
  $dccfind(*).finished
338
}
339

    
340
alias dccrun {
341
  $dccfind($1-).run
342
}
343

    
344
alias dccfind {
345
  if (!$1) {
346
    tokenize 32 $$?="Enter Search String (willdcard supported)"
347
  }
348
  if (!$get(0)) {
349
    echo -taguc info >>> No dcc gets in progress. <<<
350
    return
351
  }
352

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

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

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

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

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

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

    
373
      ; Sender
374
      %sender = $get(%i)
375

    
376
      ; Filename
377
      %filename = $get(%i).file
378
      
379
      ; Size
380
      %size = $bytes($get(%i).size,g3).suf
381
      
382
      ; Percentage
383
      %percent = $get(%i).pc $+ %
384
      
385
      ; Added
386
      %added = $duration($get(%i).secs)
387

    
388
      ; Active downloads output
389
      if (!$get(%i).done && !$get(%i).status && $prop != finished) {
390
        describe $active $($hget(DCCInfo,dccactive_ $+ $hget(DCCInfo,Active_theme)),2)
391
      }
392
      ; Inactive output
393
      elseif ($prop != active && $get(%i).done) {
394
        if ($prop == run) {
395
          run $qt($get(%i).path $+ \ $+ $get(%i).file)
396
        }
397
        else {
398
          describe $active $($hget(DCCInfo,dccfinished_ $+ $hget(DCCInfo,Active_theme)),2)
399
        }
400
      }
401
    }
402

    
403
    inc %i 
404
  }
405
}
406

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

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

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

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

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

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

    
431
    ; Inactive count
432
    if ($get(%i).done || $get(%i).status) inc %inactive
433
    inc %i 
434
  }
435

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

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

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

    
459
alias -l setTheme {
460
  hadd -m DCCInfo Active_theme $spacefix($$1-)
461
  DCCInfoSaveToDisk
462
}
463

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

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

    
474
menu channel,query {
475
  DCC Info
476
  .Theme
477
  ..Edit themes:/DCCconfig
478
  ..-
479
  ..$submenu($themesMenu($1))
480
  .-
481
  .Stats
482
  ..Transfers $chr(9) /dccstats:/dccstats
483
  ..All time stats $chr(9) /dccpermastats:/dccpermastats
484
  ..This Session stats $chr(9) /dccsessionstats:/dccsessionstats
485
  .-
486
  .Finished items $chr(9) /dccfinished:/dccfinished
487
  .Active downloads $chr(9) /dccactive:/dccactive
488
  .Find $chr(9) /dccfind:/dccfind
489
  .Run $chr(9) /dccrun:/dccrun
490
  .-
491
  .Help $chr(9) /dcchelp:/dcchelp
492
  .-
493
  .About
494
  ..$style(2) Version $DCCInfoVersion by Pereba:/
495
  ..$style(2) Beta tester Jaglag:/
496
  ..-
497
  ..Advertise $chr(9) (/DCCi):/DCCi
498
  ..-
499
  ..Forum link:run http://dev.adiirc.com/boards/5/topics/614
500
  -
501
}
(4-4/4)