IPv4 Fremnet Logo
TOOLS, TINKERINGS & CODE

If it helps

Node Usage 2 · Sept 28, 12:53 by Shannon Wynter

DO NOT USE THIS VERSION

Due to an upgrade on the node side of things, this version of Node Usage is discontinued.

Please proceed through the magic door to Node Usage 3!

Better with more options – Node Usage 3.







The node usage script for mIRC that does not require MUM to operate

Requirements

Installation
You have two options

  • You can go ALT+R and create a new script, copying and pasting the stuff below into it
  • You can grab the script from below, save it to your mIRC dir and type /load -rs nodeusage2.mrc

Troubleshooting

  • Problem: [NodeUsage2] Remote host closed socket
  • Solution: Try mIRC version 6.2 or better
  • Problem: [NodeUsage2] Socket Error (3)
  • Solution: Try mIRC version 6.2 or better

I guess what I’m trying to say is, while everything says ssl works in 6.17, if you have any problems try 6.2 – others have reported success.

  1. ;****************************************************  
  2. ;* NodeUsage Version2 0.03 **************************  
  3. ;****************************************************  
  4. ;* Writen by Freman aka Fremean                     *  
  5. ;****************************************************  
  6. ;* Pay a vist to http://fremnet.net/contact if you  *  
  7. ;* Feel the burning desire to leave comments,       *  
  8. ;* compliments, or complaints                       *  
  9. ;****************************************************  
  10. ;* To catch me look for Freman/Fremean on Gamesurge *  
  11. ;* If I'm online and around, I'll get back to you   *  
  12. ;* Home Chan(s): #ign                               *  
  13. ;****************************************************  
  14. ;* Commands:                                        *  
  15. ;*   /NodeUsage2 - Spams your usage into the chan   *  
  16. ;*   /NodeUsage  - Alias for /NodeUsage2            *  
  17. ;*   /NodeUsage2.Setup - The setup dialog           *  
  18. ;****************************************************  
  19.   
  20. ;****************************************************  
  21. ; Aliases  
  22. ;****************************************************  
  23. ; For the lazy people, I map /NodeUsage to /NodeUsage2  
  24. alias NodeUsage {  
  25.   NodeUsage2  
  26. }  
  27.   
  28. ; Spam your usage to the current window  
  29. alias NodeUsage2 {  
  30.   set %NodeUsage2.ToChannel $active  
  31.   NodeUsage2.Sanity  
  32.   if ($NodeUsage2.GetUsage) {  
  33.     var %updated = %NodeUsage2.LastUpdate  
  34.     var %used = %NodeUsage2.Used  
  35.     var %limit = %NodeUsage2.Limit  
  36.     var %reset = $asctime(%NodeUsage2.Rollover,dd/mm/yyyy)  
  37.     var %rduation = $duration($calc(%NodeUsage2.Rollover - $ctime))  
  38.     var %dration = $gettok(%rduation, $+(1-,$calc($numtok(%rduation,32)-1)),32)  
  39.   
  40.     var %daysinmonth = 31.x.31.30.31.30.31.31.30.31.30.31  
  41.   
  42.     if (%limit == 0) {  
  43.       var %text = thanks god for flatrate as [ %NodeUsage2.Gender1 ] has abused [ %NodeUsage2.Gender ] connection and downloaded [ %used ] megs.  
  44.     }  
  45.     else {  
  46.       if (%used > %limit) {  
  47.         var %text = is over [ %NodeUsage2.Gender ] %limit meg node usage limit by $calc(%used - %limit) megs, [ %dration ] till reset [Last Updated: $asctime(%updated,h:nn tt zz) $+ ]]  
  48.       }  
  49.       else {  
  50.         var %remain = $calc(%limit - %used)  
  51.         var %text = has [ %dration ] to use the remaining [ %remain megs ] of [ %NodeUsage2.Gender ] %limit meg node usage limit [Last Updated: $asctime(%updated,h:nn tt zz) $+ ]]  
  52.         if (%NodeUsage2.Averages == 1) {  
  53.           var %avgpast = $round($calc(($ctime(01:01 %reset) - $ctime)/24/60/60),0)  
  54.           %avgpast = $round($calc(%remain / %avgpast),2)  
  55.           %text = %text Average daily to end of month: %avgpast mb  
  56.         }  
  57.       }  
  58.     }  
  59.     ; If the SSL dialog pops up it breaks shit, this fixes the broken shit  
  60.     describe %NodeUsage2.ToChannel %text  
  61.   }  
  62. }  
  63.   
  64. ; Display the setup dialog  
  65. alias NodeUsage2.Setup {  
  66.   dialog -m NodeUsage2.Setup NodeUsage2.Dialog1  
  67. }  
  68.   
  69. ; Something to get around the most common problems from the first script  
  70. alias -l NodeUsage2.Sanity {  
  71.   if (%NodeUsage2.Setup != $true) {  
  72.     NodeUsage2.RaiseError I have not been setup, please /reload the script - When prompted to run the initialization commands, choose yes  
  73.   }  
  74.   if (%NodeUsage2.Username == $null) {  
  75.     NodeUsage2.RaiseError No username set, please run /NodeUsage2.Setup  
  76.   }  
  77.   if (%NodeUsage2.Password == $null) {  
  78.     NodeUsage2.RaiseError No username set, please run /NodeUsage2.Setup  
  79.   }  
  80. }  
  81.   
  82. ; Go off and fetch the usage from node's servers  
  83. alias -l NodeUsage2.GetUsage {  
  84.   ; Make sure someone hasn't done something stupid  
  85.   NodeUsage2.SSLnVersion  
  86.   ; Prevent the script from fetching data more then once per hour  
  87.   if ($calc($ctime - %NodeUsage2.LastUpdate) > 3600) {  
  88.     sockopen -e NodeUsage2 accounts.internode.on.net 443  
  89.     return $false  
  90.   }  
  91.   return $true  
  92. }  
  93.   
  94. ; Make an error message!  
  95. alias -l NodeUsage2.RaiseError {  
  96.   if ($sock(NodeUsage2).status == active) {  
  97.     sockclose NodeUsage2  
  98.   }  
  99.   if (!$line($active,0)) { linesep -a }  
  100.   echo $color(info) -a * [NodeUsage2] $1-  
  101.   linesep -a  
  102.   halt  
  103. }  
  104.   
  105. ; Check mIRC version and make sure SSL is installed  
  106. alias -l NodeUsage2.SSLnVersion {  
  107.   ; Check version  
  108.   if ($version < 6.17) {  
  109.     NodeUsage2.RaiseError I am sorry, I need mIRC 6.14 or better  
  110.     halt  
  111.   }  
  112.   ; Check for SSL support  
  113.   if ($sslready != $true) {  
  114.     NodeUsage2.RaiseError I need a SSL enabled mIRC see http://www.mirc.co.uk/ssl.html  
  115.     halt  
  116.   }  
  117. }  
  118.   
  119. ; The initialization command  
  120. alias -l NodeUsage2.Init {  
  121.   NodeUsage2.SSLnVersion  
  122.   echo 3 -as .................................  
  123.   echo 3 -as . Node Usage2 V0.01 .............  
  124.   echo 3 -as ..................... by Freman .  
  125.   echo 3 -as .................................  
  126.   echo 3 -as .. Spam the current channel .....  
  127.   echo 3 -as .............. with your usage ..  
  128.   echo 3 -as .................................  
  129.   echo 3 -as ..... Setting default vars. .....  
  130.   echo 3 -as .................................  
  131.   
  132.   set %NodeUsage2.Username  
  133.   set %NodeUsage2.Password  
  134.   set %NodeUsage2.Gender his  
  135.   set %NodeUsage2.Gender1 he  
  136.   set %NodeUsage2.Averages 1  
  137.   set %NodeUsage2.Setup $true  
  138.   
  139.   NodeUsage2.Setup  
  140. }  
  141.   
  142. ;****************************************************  
  143. ; Events  
  144. ;****************************************************  
  145. ; Executed as the script is loaded  
  146. on *:LOAD: {  
  147.   NodeUsage2.Init  
  148. }  
  149.   
  150. ; Executed as the script is unloaded  
  151. on *:UNLOAD: {  
  152.   unset %NodeUsage2.*  
  153. }  
  154.   
  155. ; Once the socket is open, we must perform a HTTP POST  
  156. on *:SOCKOPEN:NodeUsage2: {  
  157.   if ($sockerr) { NodeUsage2.RaiseError Socket Error ( $+ $sockerr $+ ) }  
  158.   sockwrite -tn $sockname POST /cgi-bin/padsl-usage HTTP/1.0  
  159.   sockwrite -tn $sockname Host: accounts.internode.on.net  
  160.   sockwrite -tn $sockname User-Agent: Fremnet-NodeUsage2/1.0  
  161.   sockwrite -tn $sockname Connection: close  
  162.   var %Content username= $+ %NodeUsage2.Username $+ @internode.on.net&password= $+ %NodeUsage2.Password  
  163.   sockwrite -tn $sockname Content-length: $len(%Content)  
  164.   sockwrite -tn $sockname  
  165.   sockwrite -tn $sockname %Content  
  166.   sockwrite -tn $sockname  
  167. }  
  168.   
  169. ; The sever is speaking back to us  
  170. on *:SOCKREAD:NodeUsage2: {  
  171.   if ($sockerr) { NodeUsage2.RaiseError Socket Error ( $+ $sockerr $+ ) }  
  172.   var %data  
  173.   sockread %data  
  174.   tokenize 32 %data  
  175.   ; Check and see if the first character is a number, if it is then  
  176.   ; it's probably our usage.  
  177.   if ($left($1,1) == $int(0 $+ $left($1,1))) {  
  178.     set %NodeUsage2.LastUpdate $ctime  
  179.     set %NodeUsage2.Used $round($1,2)  
  180.     set %NodeUsage2.Limit $2  
  181.     set %NodeUsage2.Rollover $ctime($3 01:01)  
  182.     set %NodeUsage2.ExcessRate $4  
  183.     sockclose $sockname  
  184.     ; Execute the output command again  
  185.     NodeUsage2  
  186.   }  
  187.   ; On the other hand...  
  188.   if (%data == Authentication failed) {  
  189.     NodeUsage2.RaiseError Authentication Failure - Check your username/password. Type /NodeUsage2.Setup  
  190.   }  
  191. }  
  192.   
  193. ; The server is beign rude  
  194. on *:SOCKCLOSE:NodeUsage2: {  
  195.   if ($sockerr) { NodeUsage2.RaiseError Socket Error ( $+ $sockerr $+ ) }  
  196.   NodeUsage2.RaiseError Remote host closed socket  
  197. }  
  198.   
  199. ; Executed as the dialog is opened  
  200. on *:DIALOG:NodeUsage2.Setup:init:0: {  
  201.   didtok $dname 8 46 Male.Female  
  202.   if (%NodeUsage2.Gender == his) {  
  203.     did -c $dname 8 1  
  204.   }  
  205.   else {  
  206.     did -c $dname 8 2  
  207.   }  
  208.   if (%NodeUsage2.Averages == 1) {  
  209.     did -c $dname 11  
  210.   }  
  211. }  
  212.   
  213. ; Executed when Ok is clicked  
  214. on *:DIALOG:NodeUsage2.Setup:sclick:15: {  
  215.   %NodeUsage2.Username = $did($dname,9)  
  216.   %NodeUsage2.Password = $did($dname,10)  
  217.   if ($did($dname,8).sel == 1) {  
  218.     %NodeUsage2.Gender = his  
  219.     %NodeUsage2.Gender1 = he  
  220.   }  
  221.   else {  
  222.     %NodeUsage2.Gender1 = she  
  223.     %NodeUsage2.Gender = her  
  224.   }  
  225.   %NodeUsage2.Averages = $did($dname,11).state  
  226. }  
  227.   
  228. ;***************************************************  
  229. ; Dialogs  
  230. ;***************************************************  
  231. dialog  NodeUsage2.Dialog1 {  
  232.   title "NodeUsage2 Setup"  
  233.   size -1 -1 160 62  
  234.   option dbu  
  235.   
  236.   text "Gender:",3,1 2 40 10  
  237.   text "Username:",4,1 12 40 10  
  238.   text "Password:",5,1 22 40 10  
  239.   text "@internode.on.net",6,84 12 50 10  
  240.   combo 8,42 1 50 10,drop  
  241.   edit %NodeUsage2.Username,9,42 12 40 10,autohs  
  242.   edit %NodeUsage2.Password ,10,42 22 40 10,autohs pass  
  243.   check "Display Averages",11,42 32 150 10  
  244.   
  245.   button  "OK", 15, 120 41 40 10, ok  
  246.   button  "Cancel", 16, 120 51 40 10, cancel  
  247. }  
  248.  
  249. Download this code: NodeUsage2.mrc (Downloaded 401 time(s))

Comments

Commenting is closed for this article.

---== Copyright Shannon Wynter - All rights reserved - All wrongs avenged ==---
info