mruno

moo.mrc 3.19

Jan 22nd, 2015
537
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 15.47 KB | None | 0 0
  1. ;.oO{ moo script v3.19 by HM2K }Oo. - IRC@HM2K.ORG
  2. f
  3. alias ew.moo.status {
  4.   var %reboot 0
  5.   var %ramuse $mooi(ramuse)
  6.   var %rammax $mooi(rammax)
  7.   var %usage $round($calc((%rammax - %ramuse) / %rammax * 100),2)
  8.   if (%usage > 90) { set %usage 04 $+ %usage | inc %reboot }
  9.   elseif (%usage > 70) set %usage 06 $+ %usage
  10.   elseif (%usage > 50) set %usage 07 $+ %usage
  11.   else set %usage 09 $+ %usage
  12.   set %uptime $calc($ctime - %start.time)
  13.   if (%uptime > 432000) { set %uptime 04 $+ $duration(%uptime) | inc %reboot }
  14.   elseif (%uptime > 259200) set %uptime 07 $+ $duration(%uptime)
  15.   else set %uptime 09 $+ $duration(%uptime)
  16.   msg $1 15,1 Uptime: %uptime 15Ram Usage: %usage $+ $chr(37) 
  17.   if (%reboot) msg $1 15,1 A restart is $iif(%reboot > 1,4HIGHLY) 7recommended15. 14Type !restart 
  18. }
  19.  
  20. ;description:
  21. ;no more moo.dll! -- this script uses $com to lookup the WMI functions to return specified system information.
  22. ;moo script was originally created to display your system information via IRC, including: operating system,
  23. ;  uptime, cpu, memory usage, graphics card, resolution, network details and hard drive details.
  24.  
  25. ;install:
  26. ;NOTICE: please unload and remove any old moo scripts, else this script may not work.
  27. ;make sure moo.mrc is in your $mircdir then type: /load -rs moo.mrc
  28.  
  29. ;Please make sure you have the latest windows updates or the latest WMI core (http://goo.gl/nAYpB)
  30. ;Also, please use the latest version of mIRC, ideally mIRC v6.16 or above...
  31.  
  32. ;usage:
  33. ;for moo type: /moo or !moo (if enabled)
  34. ;for uptime only type: /up or !uptime (if enabled)
  35.  
  36. ;history:
  37. ;moo script v3.19   - added better output relaying
  38. ;moo script v3.18   - added find the fastest network interface and find active graphics card
  39. ;moo script v3.17   - added cpu architecture descriptors
  40. ;moo script v3.16   - Added /stat and /statself, and fixed local echoing.
  41. ;moo script v3.15   - Fixed a few bugs + Fixed the repeat checker + Out of beta
  42. ;moo script v3.14   - Change the WMI lookup location of the rammax inline with the ramuse.
  43. ;moo script v3.13   - Changed the ram function to use a more reliable WMI location, added OSArchitecture (osarc) for Vista, fixed CPU load to not return anything if there's no load.
  44. ;moo script v3.12   - Minor tweaks, a few code changes, added /moo echo and a few more functions.
  45. ;moo script v3.11   - Added some new features and made it easier to style the output, added some additional notes
  46. ;moo script v3.1    - Added the long awaited flood protection, simple lookup error checking, more/better functions, quicker script
  47. ;moo script v3.0    - The whole script was changed, no more moo.dll, it now uses WMI however this version MUST be run on mIRC v6.16 or above.
  48. ;[moo] script v2.27 - !moo trigger fix, now turned off by default to stop abuse
  49. ;[moo] script v2.26 - Lots of little changes made up till this version, including getmoo.
  50. ;[moo] script v2.23 - changed some alias' to alias -l, fixed small bugs, added new featuers
  51. ;[moo] script v2.22 - minor bug fixes, bold added etc.
  52. ;[moo] script v2.21 - added a feature to turn the !moo get and !getmoo on or off, and fixed a few bugs.
  53. ;[moo] script v2.2  - name change, completly changed the /moo and !moo system, should work better now, no mistakes.
  54. ;moo script v2.13   - still a few mistakes, changes made, mbm5 isn't functioning correctly...
  55. ;moo script v2.12   - many small changes and fixes made, mbm5 was fixed also.
  56. ;moo script v2.11   - simple bug fixes.
  57. ;moo script v2.1    - minor modifications, final public release.
  58. ;moo script v2.0    - New name, new style, new script, same idea.
  59. ;MooDll Script v1.21    - Many bug fixes, first public release
  60. ;MooDll Script v1.0 - Original private release, very simple, buggy.
  61.  
  62. ;thanks:
  63. ;Mark (from influenced.net) for the original concept and for letting me know that he was not creating a new moo.dll
  64. ;HndlWCare who inspired me to write this for making false claims about the original moo.dll
  65.  
  66. ;support:
  67. ;Help support continued development: Please consider donating (http://tinyurl.com/hm2kpaypal). Thanks!
  68.  
  69. ;--------------------------------------------------------------------------------------------------------
  70. ;SETTINGS - START
  71. ;--------------------------------------------------------------------------------------------------------
  72.  
  73. ;moo banned channels - these are channels you don't want the triggers to function in
  74. alias -l moo.banchans return #php #windows #eztv
  75.  
  76. ;moo style - use this to style the titles of the output
  77. alias -l moos return $+(,$1,:)
  78.  
  79. ;moo prefix - style the prefix
  80. alias -l mooprefix return moo:
  81.  
  82. ;--------------------------------------------------------------------------------------------------------
  83. ;SETTINGS - END
  84. ;--------------------------------------------------------------------------------------------------------
  85.  
  86. ;NOTICE: DO NOT edit below unless you know what you're doing. If you do make any changes, please let me know! :)
  87.  
  88. alias -l moover return moo script v3.19
  89.  
  90. ;usage: /moo <os|up|cpu|gfx|res|ram|hdd|net>
  91. alias moo $iif($isid,return $stat($1),stat $1)
  92. alias stat {
  93.   if ($isid) {
  94.     if (!$mooi(name)) { return lookup error }
  95.     if (!$1) { return $mooprefix $moo(os) $moo(up) $moo(cpu) $moo(gfx) $moo(res) $moo(ram) $moo(hdd) $moo(net) }
  96.     if ($1 == os) { return $moos($1) $mooi(ostitle) - $mooi(ossp) $brak($mooi(osver)) }
  97.     if ($1 == up) { return $moos($1) $duration($mooi(up)) }
  98.     if ($1 == cpu) { return $moos($1) $mooi(cpuname) $brak($mooi(cpuarch)) at $mooi(cpuspeed) $mooi(cpuload) }
  99.     if ($1 == gfx) { return $moos($1) $mooi(gfxmake) $mooi(gfxproc) $mooi(gfxram) }
  100.     if ($1 == res) { return $moos($1) $mooi($1) $mooi(resbit) $mooi(resrate) }
  101.     if ($1 == ram) { var %moo.rammax = $mooi(rammax) | var %moo.ramuse = $mooi(ramuse) | return $moos($1) $+($round($calc(%moo.rammax - %moo.ramuse),0),/,%moo.rammax,MB) $+($chr(40),$round($calc((%moo.rammax - %moo.ramuse) / %moo.rammax * 100),2),%,$chr(41)) $moorambar($round($calc((%moo.rammax - %moo.ramuse) / %moo.rammax * 100),2)) }
  102.     if ($1 == hdd) { return $moos($1) $mooi(hdd) }
  103.     if ($1 == net) { return $moos($1) $iif($mooi(netname),$ifmatch $iif($mooi(netspeed), - $ifmatch, ) $mooi(netin) In $mooi(netout) Out, ) }
  104.     elseif ($mooi($1)) { return $moos($1) $ifmatch }
  105.   }
  106.   var %out $relay($active)
  107.   if (!$1) { %out $moo | return }
  108.   if ($moo($1)) { %out $mooprefix $ifmatch }
  109. }
  110. alias mooecho {
  111.   var %out echo $color(info2) -gat
  112.   if (!$1) { %out $moo | return }
  113.   if ($moo($1)) { %out $mooprefix $ifmatch }
  114. }
  115. alias statself mooecho $1-
  116.  
  117. alias -l relay { ;output relay v0.05 by HM2K
  118.   ;default
  119.   var %out echo $color(info2) -gat
  120.   ;channel command
  121.   var %chanmsg msg
  122.   ;user action
  123.   var %usermsg msg
  124.  
  125.   if ($modespl) {
  126.     if ($1) {
  127.       if (!$gettok($1,2,32)) {
  128.         if ($left($1,1) != $chr(35)) { var %out %chanmsg $1 }
  129.         elseif ($chan($1)) { var %out %chanmsg $1 }
  130.       }
  131.     }
  132.     elseif (($nick) && ($nick != $me)) { var %out %usermsg $nick }
  133.   }
  134.   if ($isid) { return %out }
  135.   %out $1-
  136. }
  137.  
  138. ;info - below are the useful or interesting wmi functions to use with the script
  139. alias mooi {
  140.   if ($1 == name) { return $wmiget(Win32_ComputerSystem).Name }
  141.   if ($1 == ostitle) { return $wmiget(Win32_OperatingSystem).Caption }
  142.   if ($1 == ossp) { return $wmiget(Win32_OperatingSystem).CSDVersion }
  143.   if ($1 == osver) { return $wmiget(Win32_OperatingSystem).Version }
  144.   if ($1 == osinstall) { var %time = $ctime($iif($wmiget(Win32_OperatingSystem).InstallDate,$+($mid($ifmatch,7,2),/,$mid($ifmatch,5,2),/,$mid($ifmatch,1,4)) $+($mid($ifmatch,9,2),:,$mid($ifmatch,11,2),:,$mid($ifmatch,13,2)))) | return $asctime(%time) $brak($duration($calc($ctime - %time)) ago) }
  145.   if ($1 == osarc) { return $wmiget(Win32_OperatingSystem).OSArchitecture }
  146.   if ($1 == up) { return $uptime(system,3) }
  147.   if ($1 == cpuname) { return $wmiget(Win32_Processor).Name }
  148.   if ($1 == cpuspeed) { return $+($wmiget(Win32_Processor).CurrentClockSpeed,MHz) }
  149.   if ($1 == cpuload) { return $iif($wmiget(Win32_Processor).LoadPercentage,$brak($+($ifmatch,% Load)),) }
  150.   if ($1 == cputotal) { return $wmiget(Win32_ComputerSystem).NumberOfProcessors }
  151.   if ($1 == cpuarch) { return $mooarch($wmiget(Win32_Processor).Architecture) }
  152.   if ($1 == gfxmake) { return $wmiget(Win32_VideoController,$moogfx).AdapterCompatibility }
  153.   if ($1 == gfxproc) { return $wmiget(Win32_VideoController,$moogfx).VideoProcessor }
  154.   ;if ($1 == gfxproc) { return $wmiget(CIM_VideoController,$moogfx).Description }
  155.   if ($1 == gfxram) { return $bytes($wmiget(Win32_VideoController,$moogfx).AdapterRam,3).suf }
  156.   if ($1 == res) { return $+($wmiget(Win32_VideoController,$moogfx).currenthorizontalresolution,x,$wmiget(Win32_VideoController).currentverticalresolution) }
  157.   if ($1 == resbit) { return $wmiget(Win32_VideoController,$moogfx).currentbitsperpixel $+ bit }
  158.   if ($1 == resrate) { return $wmiget(Win32_VideoController,$moogfx).currentrefreshrate $+ Hz }
  159.   if ($1 == rammax) { return $round($calc($wmiget(Win32_OperatingSystem).TotalVisibleMemorySize / 1024),1) }
  160.   if ($1 == ramuse) { return $round($calc($wmiget(Win32_OperatingSystem).FreePhysicalMemory / 1024), 1) }
  161.   if ($1 == netname) { return $wmiget(Win32_PerfRawData_Tcpip_NetworkInterface,$mooni).Name }
  162.   if ($1 == netspeed) { return $calc($wmiget(Win32_PerfRawData_Tcpip_NetworkInterface,$mooni).CurrentBandwidth / 1000000) $+ MB/s }
  163.   if ($1 == netin) { return $bytes($wmiget(Win32_PerfRawData_Tcpip_NetworkInterface,$mooni).BytesReceivedPersec).suf }
  164.   if ($1 == netout) { return $bytes($wmiget(Win32_PerfRawData_Tcpip_NetworkInterface,$mooni).BytesSentPersec).suf }
  165.   if ($1 == hdd) { var %i 1 | while (%i <= $disk(0)) { if ($disk(%i).type == fixed) var %var %var $disk(%i).path $+($bytes($disk(%i).free).suf,/,$bytes($disk(%i).size).suf) | inc %i } | return %var }
  166.   if ($1 == sound) { return $wmiget(Win32_SoundDevice).Name }
  167.   if ($1 == mobo) { return $wmiget(Win32_BaseBoard).Manufacturer $wmiget(Win32_BaseBoard).Product }
  168. }
  169.  
  170. ;find active graphics card
  171. alias -l moogfx {
  172.   var %i = 1, %t = $wmiget(Win32_VideoController,-1).Availability
  173.   while (%i < %t) {
  174.     if ($wmiget(Win32_VideoController,%i).Availability == 3) { return %i }
  175.     inc %i
  176.   }
  177. }
  178.  
  179. ;find fastest network interface
  180. alias mooni {
  181.   var %i = 0, %s = 0, %n = 0
  182.   %t = $wmiget(Win32_PerfRawData_Tcpip_NetworkInterface,-1).CurrentBandwidth
  183.   while (%i < %t) {
  184.     inc %i
  185.     %ns = $wmiget(Win32_PerfRawData_Tcpip_NetworkInterface,%i).CurrentBandwidth
  186.     if (%ns >= %s) {
  187.       %s = %ns
  188.       %n = %i
  189.     }
  190.   }
  191.   return %n
  192. }
  193.  
  194. ;cpu architecture descriptors
  195. alias -l mooarch {
  196.   if ($1 == 0) { return x86 }
  197.   if ($1 == 1) { return MIPS }
  198.   if ($1 == 2) { return Alpha }
  199.   if ($1 == 3) { return PowerPC }
  200.   if ($1 == 6) { return Intel Itanium Processor Family (IPF) }
  201.   if ($1 == 9) { return x64 }
  202. }
  203.  
  204. ;rambar - the famous rambar from the original script with a couple of changes
  205. alias -l moorambar {
  206.   if ($len($1) < 990) {
  207.     var %moo.rb.size = 10
  208.     var %moo.rb.used = $round($calc($1 / 100 * %moo.rb.size),0)
  209.     var %moo.rb.unused = $round($calc(%moo.rb.size - %moo.rb.used),0)
  210.     var %moo.rb.usedstr = $str(|,%moo.rb.used)
  211.     var %moo.rb.unusedstr = $str(-,%moo.rb.unused)
  212.     if ((%moo.rb.usedstr) && (%moo.rb.unusedstr)) return $+([,%moo.rb.usedstr,%moo.rb.unusedstr,])
  213.   }
  214. }
  215.  
  216. ;Get WMI data - this is the most useful function here, this only works if mIRC has the $COM function, its very useful, but a little slow.
  217. alias wmiget {
  218.   var %com = cominfo, %com2 = cominfo2, %com3 = cominfo3
  219.   if ($com(%com)) { .comclose %com }
  220.   if ($com(%com2)) { .comclose %com2 }
  221.   if ($com(%com3)) { .comclose %com3 }
  222.   .comopen %com WbemScripting.SWbemLocator
  223.   var %x = $com(%com,ConnectServer,3,dispatch* %com2), %x = $com(%com2,ExecQuery,3,bstr*,select $prop from $1,dispatch* %com3), %x = $comval(%com3,$iif($2,$2,1),$prop)
  224.   if ($com(%com)) { .comclose %com }
  225.   if ($com(%com2)) { .comclose %com2 }
  226.   if ($com(%com3)) { .comclose %com3 }
  227.   return %x
  228. }
  229.  
  230. ;backets - I got fed up of repeating the same thing
  231. alias -l brak return $+($chr(40),$1-,$chr(41))
  232.  
  233. ;uptime script - this is the short uptime script created to return your current update and retain your best uptime
  234. on *:connect: up x
  235. alias up { ;uptime v0.4
  236.   $iif($timer(up) == $null,.timerup 0 60 up x)
  237.   if (($uptime(system,3) >= %up) || (%up == $null)) set %up $uptime(system,3)
  238.   $iif($1 == x,halt,$iif($chan,msg $chan,$iif($active == Status Window,echo,say)) $+(Windows,2000) Uptime: $uptime(system,1) Best: $duration(%up))
  239. }
  240.  
  241. #!uptime off
  242. on *:text:!uptime:#: if (!$istok($moo.banchans,$chan,32)) { up | $repeatcheck(!uptime) }
  243. #!uptime end
  244.  
  245. ;moo triggers - public display, sharing the script and ctcp moo
  246.  
  247. #!moo off
  248. on *:text:!moo*:#: if (!$istok($moo.banchans,$chan,32)) { $relay($chan) $moo($2) | $repeatcheck(!moo) }
  249. #!moo end
  250. #!getmoo off
  251. on *:text:!getmoo:*: {
  252.   if ($chan) { .notice $nick moo: To get $moover type: "/msg $me !getmoo" (set "/dccignore off" first) | $repeatcheck(!getmoo) | halt }
  253.   else { .close -m $nick | .dcc send $nick $script | .notice $nick moo: Once you receive the script issue: "/load -rs $nopath($script) $+ ", and don't forget to do "/dccignore on" | $repeatcheck(!getmoo) | halt }
  254. }
  255. #!getmoo end
  256. #ctcpmoo off
  257. ctcp *:*:*: if (($1 == MOO) || ($1 == VERSION)) { .ctcpreply $nick $1 $moover by HM2K | $repeatcheck(ctcpmoo) }
  258. #ctcpmoo end
  259.  
  260. alias -l repeatcheck { ;v0.12 by HM2K - will disable the appropriate group if its flooded
  261.   var %rep.lim = 3
  262.   var %rep.t.lim = 25
  263.   var %rep.t.expr = 10
  264.   if (%rep.lockusr- [ $+ [ $nick ] ]) { echo $ifmatch | haltdef }
  265.   inc $+(-u,%rep.t.lim,$chr(32),%,rep-,$nick,.,$len($strip($1-)),.,$hash($strip($1-),32)) 1
  266.   if (%rep- [ $+ [ $nick ] $+ . $+ [ $len($strip($1-)) ] $+ . $+ [ $hash($strip($1-),32) ] ] == %rep.lim) {
  267.     ;ignore -u60 $address($nick,5)
  268.     if ($group($chr(35) $+ $1) == on) { .disable $chr(35) $+ $1 | .echo -gat $1 is $group($chr(35) $+ $1) due to a repeat flood from $iif($chan,$nick in $chan,$nick) $+ , to re-enable: /enable $chr(35) $+ $1 }
  269.     .set $+(-u,%rep.t.expr,$chr(32),%,rep.lockusr-,$nick) 1
  270.   }
  271. }
  272.  
  273. ;onload and onunload checks - making sure everything is as it should be
  274. on *:load: { up x | if ($version < 6.16) { echo -a moo: you need mIRC v6.16 or greater to run this script, get the latest version from www.mirc.com/get.html | unload -rs $script | halt } }
  275. on *:unload: { .timerup off | $iif($input(Do you want to remove the best uptime data,y,unset %up),unset %up,) | .echo $colour(info2) -gat $moover was unloaded, to reload type: /load -rs $script }
  276.  
  277. ;the menus - only simple at the moment, however this script is designed to utilise the /moo and !moo triggers
  278. menu channel,query {
  279.   $moover
  280.   .moo all (/moo): moo
  281.   .moo uptime (/up): up
  282.   .-
  283.   .!moo trigger ( $+ $group(#!moo) $+ ):{
  284.     if ($group(#!moo) != on) { .enable #!moo }
  285.     else { .disable #!moo }
  286.     .echo -ga moo: !moo is $group(#!moo)
  287.   }
  288.   .!uptime trigger ( $+ $group(#!uptime) $+ ):{
  289.     if ($group(#!uptime) != on) { .enable #!uptime }
  290.     else { .disable #!uptime }
  291.     .echo -ga moo: !uptime is $group(#!uptime)
  292.   }
  293.   .!getmoo trigger ( $+ $group(#!getmoo) $+ ):{
  294.     if ($group(#!getmoo) != on) { .enable #!getmoo }
  295.     else { .disable #!getmoo }
  296.     .echo -ga moo: !getmoo is $group(#!getmoo)
  297.   }
  298.   .ctcp moo trigger ( $+ $group(#ctcpmoo) $+ ):{
  299.     if ($group(#ctcpmoo) != on) { .enable #ctcpmoo }
  300.     else { .disable #ctcpmoo }
  301.     .echo -ga moo: ctcpmoo is $group(#ctcpmoo)
  302.   }
  303.   .-
  304.   .unload $remove($script,$scriptdir)
  305.   ..are you sure?
  306.   ...yes: { .unload -rs $script }
  307.   ...no: { .echo $colour(info2) -gat $remove($script,$scriptdir) was NOT unloaded. }
  308. }
  309. ;EOF
Add Comment
Please, Sign In to add comment