Advertisement
westor

Auto upload stats for multi network channels DEBUG

Nov 9th, 2014
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 2.34 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.       var %f = $mkfn(%f)
  16.       set -e %upload_stats $addtok(%upload_stats,%f,32)
  17.       inc %ii
  18.     }
  19.     inc %i
  20.   }
  21.   echo -a ALL: %upload_stats
  22.   if (%upload_stats) { upload_stats_start }
  23. }
  24.  
  25. alias upload_stats_start {
  26.   :again
  27.   var %mf = C:\mircstats\mircstats.exe
  28.   if (!$isfile(%mf)) { .timer[UPLOAD_STATS] off | return }
  29.   if (!%upload_stats) { .timer[UPLOAD_STATS] off | return }
  30.   var %g = $gettok(%upload_stats,$rand(1,$numtok(%upload_stats,32)),32)
  31.   var %network = $gettok(%g,$calc($numtok(%g,46) -1),46)
  32.   var %cid = $get_cid(%network)
  33.   var %status = $scid(%cid).status
  34.   var %chan = $gettok(%g,1,46)
  35.   var %file = $logdir $+ %g
  36.   var %size = $iif($bytes($file(%file).size).suf,$v1,0)
  37.   var %lines = $lines(%file)
  38.   var %link = http://stats.3-a.net/irc/ $+ $remove(%chan,$chr(35)) $+ . $+ %network $+ .html
  39.   set -e %upload_stats $remtok(%upload_stats,%g,1,32)
  40.   if (!$isfile(%file)) { echo -a Error, NOT ANY FILE $qt($longfn(%file)) -> %g -> %network -> %cid -> %status -> %chan -> shortfn: $shortfn(%file) -> %size -> %lines -> %link | goto again }
  41.   if (!$lines(%file)) { echo -a Error, NOT ANY LINES $qt($longfn(%file)) | goto again }
  42.   .run -nh $qt(%mf) -log $qt(%file) -cfg settings.cfg
  43.   .timer[UPLOAD_STATS] 1 30 upload_stats_start
  44.   if (%status == connected) {
  45.     scid %cid
  46.     .msg %chan [ $+ %chan $+ ]: Generating the channel statistics... - (Log Size:  $+ %size $+ ) - (Log Lines:  $+ %lines $+ ) - (Link:  $+ %link $+ )
  47.   }
  48. }
  49.  
  50. alias get_cid {
  51.   if (!$1) { return 0 }
  52.   var %p = $1
  53.   var %t = $scon(0)
  54.   var %i = 1
  55.   while (%i <= %t) {
  56.     var %c = $scon(%i).cid
  57.     var %n = $scon(%i).network
  58.     if (%p == %n) { var %tot = %c }
  59.     inc %i
  60.   }
  61.   if (!%tot) { return 0 }
  62.   elseif (%tot) { return %tot }
  63. }
  64.  
  65. alias allchans {
  66.   var %t = $chan(0)
  67.   var %i = 1
  68.   while (%i <= %t) {
  69.     var %c = $chan(%i)
  70.     if ($me ison %c) { var %tot = $addtok(%tot,%c,44) }
  71.     inc %i
  72.   }
  73.   return $iif(%tot,$v1,0)
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement