Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.98 KB | None | 0 0
  1. alias stat { nndlg -m stat }
  2. dialog stat {
  3. title "Script statistics [/stat]"
  4. size -1 -1 312 264
  5. option pixels
  6. icon scripts\pics\nntray.ico
  7. tab "General", 7, 5 4 302 230
  8. tab "Conversation", 3
  9. tab "DCC", 6
  10. list 2, 10 30 292 158, size
  11. button "&Ok", 1, 228 236 80 24, ok
  12. text "Last reset:", 8, 12 192 56 16
  13. text "", 9, 80 192 220 16, right
  14. text "", 10, 80 206 220 16, right
  15. menu "&File", 11
  16. item "&Close", 12, 11
  17. menu "&Statistics", 4
  18. item "&Post selected in active", 14, 4
  19. item break, 15, 4
  20. item "&Refresh", 13, 4
  21. item "R&eset", 5, 4
  22. }
  23. alias stat.scriptlines {
  24. var %a = $alias(0),%s = $script(0),%l = 0
  25. while (%a) {
  26. inc %l $lines($alias(%a))
  27. dec %a
  28. }
  29. while (%s) {
  30. inc %l $lines($script(%s))
  31. dec %s
  32. }
  33. return %l
  34. }
  35. alias stat.lastreset { return $sduration($calc($ctime - %stat.lastreset)).nosec }
  36. alias stat.ref {
  37. did -ra stat 9 $longtime(%stat.lastreset)
  38. did -ra stat 10 $stat.lastreset ago
  39. did -r stat 2
  40. if ($1 == -c) {
  41. did -a stat 2 1 + 0 0 0 $bytes(%stat.writtenchars,b) $+ + 0 0 0 Written characters
  42. did -a stat 2 1 + 0 0 0 $bytes(%stat.writtenwords,b) $+ + 0 0 0 Written words
  43. did -a stat 2 1 + 0 0 0 $bytes(%stat.writtenlines,b) $+ + 0 0 0 Written lines
  44. did -a stat 2 1 + 0 0 0 $bytes(%stat.writtenqu,b) $+ + 0 0 0 Questions asked
  45. did -a stat 2 1 + 0 0 0 $bytes(%stat.queries,b) $+ + 0 0 0 Queries
  46. did -a stat 2 1 + 0 0 0 $bytes(%stat.queriestoday,b) $+ + 0 0 0 Queries today
  47. }
  48. elseif ($1 == -d) {
  49. did -a stat 2 1 + 0 0 0 $bytes(%stat.dccgotfiles,b) $+ + 0 0 0 Files received
  50. did -a stat 2 1 + 0 0 0 $bytes(%stat.dccgot,3).suf $+ + 0 0 0 Data received
  51. did -a stat 2 1 + 0 0 0 $bytes(%stat.dccsentfiles,b) $+ + 0 0 0 Files sent
  52. did -a stat 2 1 + 0 0 0 $bytes(%stat.dccsent,3).suf $+ + 0 0 0 Data sent
  53. }
  54. else {
  55. did -a stat 2 1 + 0 0 0 $bytes(%stat.scriptstarts,b) $+ + 0 0 0 Script starts
  56. did -a stat 2 1 + 0 0 0 $bytes($calc($script(0) + $alias(0)),b) $+ + 0 0 0 Script files loaded
  57. did -a stat 2 1 + 0 0 0 $bytes($stat.scriptlines,b) $+ + 0 0 0 Script lines
  58. did -a stat 2 1 + 0 0 0 $bytes(%stat.scriptcrashes,b) $+ + 0 0 0 Abnormal script shutdowns
  59. did -a stat 2 1 + 0 0 0 $bytes(%stat.thmload,b) $+ + 0 0 0 Themes loaded
  60. did -a stat 2 1 + 0 0 0 $bytes(%stat.connects,b) $+ + 0 0 0 Connects
  61. did -a stat 2 1 + 0 0 0 $bytes(%stat.joins,b) $+ + 0 0 0 Channels joined
  62. did -a stat 2 1 + 0 0 0 $bytes(%stat.nicks,b) $+ + 0 0 0 Nick changes
  63. did -a stat 2 1 + 0 0 0 $bytes(%stat.topicchanges,b) $+ + 0 0 0 Topic changes
  64. did -a stat 2 1 + 0 0 0 $bytes(%stat.opped,b) $+ + 0 0 0 Users opped
  65. did -a stat 2 1 + 0 0 0 $bytes(%stat.voiced,b) $+ + 0 0 0 Users voiced
  66. did -a stat 2 1 + 0 0 0 $bytes(%stat.deopped,b) $+ + 0 0 0 Users deopped
  67. did -a stat 2 1 + 0 0 0 $bytes(%stat.devoiced,b) $+ + 0 0 0 Users devoiced
  68. did -a stat 2 1 + 0 0 0 $bytes($power,b) $+ + 0 0 0 Users controlled
  69. did -a stat 2 1 + 0 0 0 $bytes(%stat.kickcount,b) $+ + 0 0 0 Users kicked
  70. did -a stat 2 1 + 0 0 0 $bytes(%stat.bancount,b) $+ + 0 0 0 Users banned
  71. did -a stat 2 1 + 0 0 0 $bytes(%stat.skickcount,b) $+ + 0 0 0 Been kicked
  72. did -a stat 2 1 + 0 0 0 $bytes(%stat.sbancount,b) $+ + 0 0 0 Been banned
  73. did -a stat 2 1 + 0 0 0 $bytes(%stat.away,b) $+ + 0 0 0 Gone away
  74. }
  75. }
  76. on *:dialog:stat:*:*:{
  77. if ($devent == init) {
  78. mdx SetControlMDX $dname 2 ListView report showsel single rowselect infotip > $mdxfile(views)
  79. did -i $dname 2 1 headerdims 80:1 180:2
  80. did -i $dname 2 1 headertext +r 0 Value + 0 Description
  81. did -b $dname 14
  82. stat.ref
  83. }
  84. elseif ($devent == sclick) {
  85. if ($did == 4) { stat.ref $replace($dialog($dname).tab,7,-g,6,-d,3,-c) }
  86. elseif ($did == 2) {
  87. did $iif($did($did).sel,-e,-b) $dname 14
  88. sortmdx $dname $did
  89. if (rclick * iswm $did($did,1)) {
  90. popdll.new
  91. popdll.add 1 $+ $iif($nomsg,+g,+) 1 0 &Post in activestat.say $active
  92. popdll.add 2 + 2 0 -
  93. popdll.add 3 + 3 0 &Refreshstat.ref $replace($dialog($dname).tab,7,-g,3,-c,6,-d)
  94. popdll.add 4 + 4 0 Re&set allstat.reset -v
  95. popdll.disp
  96. }
  97. }
  98. elseif ($did == 7) { stat.ref -g }
  99. elseif ($did == 6) { stat.ref -d }
  100. elseif ($did == 3) { stat.ref -c }
  101. }
  102. elseif ($devent == menu) {
  103. if ($did == 5) { stat.reset -v }
  104. elseif ($did == 13) { stat.ref $replace($dialog($dname).tab,7,-g,3,-c,6,-d) }
  105. elseif ($did == 12) { dialog -c $dname }
  106. elseif ($did == 14) { stat.say $active }
  107. }
  108. }
  109. alias stat.say {
  110. var %x = $1
  111. tokenize 9 $did(stat,2).seltext
  112. var %a,%t = $dialog(stat).tab,%s = $did(stat,2).sel
  113. if (%t == 7) {
  114. if (%s == 2) { %a = $bytes(%stat.scriptstarts,b) $nbr($dayavg(%stat.scriptstarts,1) per day) }
  115. elseif (%s == 3) { %a = $script(0) remote file(s), $alias(0) alias(es) }
  116. elseif (%s == 4) { %a = $bytes($stat.scriptlines,b) }
  117. elseif (%s == 5) { %a = $bytes(%stat.scriptcrashes,b) $nbr($dayavg(%stat.scriptcrashes,1) per day) }
  118. elseif (%s == 6) { %a = $bytes(%stat.thmload,b) $nbr($dayavg(%stat.thmload,1) per day) }
  119. elseif (%s == 7) { %a = $bytes(%stat.connects,b) $nbr($dayavg(%stat.connects,1) per day) }
  120. elseif (%s == 8) { %a = $bytes(%stat.joins,b) $nbr($dayavg(%stat.joins,1) per day) }
  121. elseif (%s == 9) { %a = $bytes(%stat.nicks,b) $nbr($dayavg(%stat.nicks,1) per day) }
  122. elseif (%s == 10) { %a = $bytes(%stat.topicchanges,b) $nbr($dayavg(%stat.topicchanges,1) per day) }
  123. elseif (%s == 11) { %a = $bytes(%stat.opped,b) $nbr($dayavg(%stat.opped,1) per day) }
  124. elseif (%s == 12) { %a = $bytes(%stat.voiced,b) $nbr($dayavg(%stat.voiced,1) per day) }
  125. elseif (%s == 13) { %a = $bytes(%stat.deopped,b) $nbr($dayavg(%stat.deopped,1) per day) }
  126. elseif (%s == 14) { %a = $bytes(%stat.devoiced,b) $nbr($dayavg(%stat.devoiced,1) per day) }
  127. elseif (%s == 15) { %a = $bytes($power,b) }
  128. elseif (%s == 16) { %a = $bytes(%stat.kickcount,b) $nbr($dayavg(%stat.kickcount,1) per day) }
  129. elseif (%s == 17) { %a = $bytes(%stat.bancount,b) $nbr($dayavg(%stat.bancount,1) per day) }
  130. elseif (%s == 18) { %a = $bytes(%stat.skickcount,b) $nbr($dayavg(%stat.skickcount,1) per day) }
  131. elseif (%s == 19) { %a = $bytes(%stat.sbancount,b) $nbr($dayavg(%stat.sbancount,1) per day) }
  132. elseif (%s == 20) { %a = $bytes(%stat.away,b) $nbr($dayavg(%stat.away,1) per day) }
  133. }
  134. elseif (%t == 3) {
  135. if (%s == 2) { %a = $bytes(%stat.writtenchars,b) $nbr($round($calc(%stat.writtenchars / %stat.writtenlines),1) per line $+ $chr(44) $round($calc(%stat.writtenchars / %stat.writtenwords),1) per word $+ $chr(44) $round($calc(%stat.writtenchars /(($ctime - %install.time)/60)),1) character(s) per minute) }
  136. elseif (%s == 3) { %a = $bytes(%stat.writtenwords,b) $nbr($round($calc(%stat.writtenwords / %stat.writtenlines),1) per line $+ $chr(44) $round($calc(%stat.writtenchars / %stat.writtenwords),1) character(s) per word $+ $chr(44) $round($calc(%stat.writtenwords /(($ctime - %install.time)/60)),1) word(s) per minute) }
  137. elseif (%s == 4) { %a = $bytes(%stat.writtenlines,b) $nbr($round($calc(%stat.writtenchars / %stat.writtenlines),1) character(s) per line $+ $chr(44) $round($calc(%stat.writtenwords / %stat.writtenlines),1) word(s) per line $+ $chr(44) $round($calc(%stat.writtenlines /(($ctime - %install.time)/60)),1) line(s) per minute) }
  138. elseif (%s == 5) { %a = $bytes(%stat.writtenqu,b) (every $ord($round($calc(%stat.writtenlines / %stat.writtenqu),0)) line you write is a question.) }
  139. elseif (%s == 6) { %a = $bytes(%stat.queries,b) $nbr($dayavg(%stat.queries,1) per day) }
  140. elseif (%s == 7) { %a = $bytes(%stat.queriestoday,b) }
  141. }
  142. elseif (%t == 6) {
  143. if (%s == 2) { %a = $bytes(%stat.dccgotfiles,b) $nbr($dayavg(%stat.dccgotfiles,1) per day $+ $chr(44) $bytes($calc(%stat.dccgot / %stat.dccgotfiles),3).suf per file) }
  144. elseif (%s == 3) { %a = $bytes(%stat.dccgot,3).suf $nbr(average $bytes($calc(%stat.dccgot /(($ctime - %install.time)))).suf $+ /s $+ $chr(44) $bytes($calc(%stat.dccgot / %stat.dccgotfiles),3).suf per file) }
  145. elseif (%s == 4) { %a = $bytes(%stat.dccsentfiles,b) $nbr($dayavg(%stat.dccsentfiles,1) per day $+ $chr(44) $bytes($calc(%stat.dccsent / %stat.dccsentfiles),3).suf per file) }
  146. elseif (%s == 5) { %a = $bytes(%stat.dccsent,3).suf $nbr(average $bytes($calc(%stat.dccsent /(($ctime - %install.time)))).suf $+ /s $+ $chr(44) $bytes($calc(%stat.dccsent / %stat.dccsentfiles),3).suf per file) }
  147. }
  148. msg %x $sbr(Statistics) $wd($2,5-) $+ : %a $nbr(last reset: $stat.lastreset ago)
  149. }
  150. alias stat.reset {
  151. if ($1 == -v) && (!$ydialog(Do you really want to reset all script statistics?)) { return }
  152. set %stat.lastreset $ctime | set %stat.writtenchars 0 | set %stat.writtenwords 0 | set %stat.writtenlines 0
  153. set %stat.writtenqu 0 | set %stat.queries 0 | set %stat.queriestoday 0 | set %stat.dccgotfiles 0
  154. set %stat.dccgot 0 | set %stat.dccsentfiles 0 | set %stat.dccsent 0 | set %stat.scriptstarts 0
  155. set %stat.scriptcrashes 0 | set %stat.connects 0 | set %stat.joins 0 | set %stat.nicks 0
  156. set %stat.topicchanges 0 | set %stat.opped 0 | set %stat.voiced 0 | set %stat.deopped 0
  157. set %stat.devoiced 0 | set %stat.kickcount 0 | set %stat.bancount 0 | set %stat.skickcount 0
  158. set %stat.sbancount 0 | set %stat.thmload 0 | set %stat.away 0
  159. if ($dialog(stat)) { stat.ref $replace($dialog($dname).tab ,3,-c,6,-d) }
  160. }
  161. alias stat.queryref {
  162. if (%querydate != $date) {
  163. set %querydate $date
  164. set %stat.queriestoday 0
  165. }
  166. inc %stat.queriestoday
  167. inc %stat.queries
  168. }
  169. on *:active:*:{ if ($dialog(stat)) { did $iif(!$did(stat,2).sel || $nomsg,-b,-e) stat 14 } }
  170. on *:op:#:{ if ($nick == $me) { inc %stat.opped } }
  171. on *:deop:#:{ if ($nick == $me) { inc %stat.deopped } }
  172. ; ––––––––––––––––––––––––––––––––––––––––
  173. ; End of file
  174. ; ––––––––––––––––––––––––––––––––––––––––
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement