Advertisement
westor

Auto upload stats for multi network channels v3.0

Nov 8th, 2014
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 1.87 KB | None | 0 0
  1. alias update_stats {
  2.   var %mf = C:\mircstats\mircstats.exe
  3.   if (!$isfile(%mf)) { return }
  4.   if (%upload_stats) { return }
  5.   var %t = $scon(0)
  6.   var %i = 1
  7.   while (%i <= %t) {
  8.     var %n = $scon(%i).network
  9.     var %c = $scon(%i).allchans
  10.     var %ii = 1
  11.     var %tt = $numtok(%c,44)
  12.     while (%ii <= %tt) {
  13.       var %chan = $gettok(%c,%ii,44)
  14.       var %f = %chan $+ . $+ %n $+ .log
  15.       set -e %upload_stats $addtok(%upload_stats,%f,32)
  16.       inc %ii
  17.     }
  18.     inc %i
  19.   }
  20.   if (%upload_stats) { upload_stats_start }
  21. }
  22.  
  23. alias upload_stats_start {
  24.   :again
  25.   var %mf = C:\mircstats\mircstats.exe
  26.   if (!$isfile(%mf)) { .timer[UPLOAD_STATS] off | return }
  27.   if (!%upload_stats) { .timer[UPLOAD_STATS] off | return }
  28.   var %g = $gettok(%upload_stats,$rand(1,$numtok(%upload_stats,32)),32)
  29.   var %network = $gettok(%g,$calc($numtok(%g,46) -1),46)
  30.   var %cid = $get_cid(%network)
  31.   var %chan = $gettok(%g,1,46)
  32.   var %file = $logdir $+ %g
  33.   var %size = $bytes(%file).suf
  34.   var %lines = $lines(%file)
  35.   set -e %upload_stats $remtok(%upload_stats,%g,1,32)
  36.   if (!$isfile(%file)) { goto again }
  37.   if (!$lines(%file)) { goto again }
  38.   .run -nh $qt(%mf) -log $qt(%file) -cfg settings.cfg
  39.   .timer[UPLOAD_STATS] 1 30 upload_stats_start
  40.   scid %cid
  41.   .msg %chan [ $+ %chan $+ ]: Uploading now the channel statistics... - (Log Size:  $+ %size $+ ) - (Log Lines:  $+ %lines $+ )
  42. }
  43.  
  44. alias get_cid {
  45.   if (!$1) { return 0 }
  46.   var %p = $1
  47.   var %t = $scon(0)
  48.   var %i = 1
  49.   while (%i <= %t) {
  50.     var %c = $scon(%i).cid
  51.     var %n = $scon(%i).network
  52.     if (%p == %n) { var %tot = %c }
  53.     inc %i
  54.   }
  55.   if (!%tot) { return 0 }
  56.   elseif (%tot) { return %tot }
  57. }
  58.  
  59. alias allchans {
  60.   var %t = $chan(0)
  61.   var %i = 1
  62.   while (%i <= %t) {
  63.     var %c = $chan(%i)
  64.     if ($me ison %c) { var %tot = $addtok(%tot,%c,44) }
  65.     inc %i
  66.   }
  67.   return $iif(%tot,$v1,0)
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement