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 4!
Now with Auto-Update – Node Usage 4.
Greetings once again folks.
The wonderful people at Internode have upgraded their API’s for us, making them more secure and sane in the process. So I’ve had to make a new Node Usage update.
As a bonus (And mostly because I was bored) I’ve almost completely re-written the script, you can now customize a lot more of it and even brag about your line speed (As seen by node, not you)
Requirements
Installation
You have two options
;*********************************************************** ;* NodeUsage Version 3.00 ********************************** ;*********************************************************** ;* Writen by Freman aka Fremean * ;*********************************************************** ;* NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE * ;* * ;* If you wish to create your own usage meter interface, * ;* do not copy the interface from this script, please * ;* contact Internode at support@internode.on.net for the * ;* specifications document * ;* * ;* NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE * ;*********************************************************** ;* Pay a vist to http://fremnet.net/contact if you feel * ;* the burning desire to leave comments, compliments, or * ;* complaints * ;*********************************************************** ;* To catch me look for Freman/Fremean on Gamesurge. If * ;* I'am online and around, I'll get back to you * ;* Home Chan(s): #gamesonnet * ;*********************************************************** ;* Commands: * ;* /NodeUsage - The spam command * ;* /NodeUsage.Setup - The setup dialog * ;*********************************************************** ;*********************************************************** ; Public Aliases ;*********************************************************** ; Main alias alias NodeUsage { ; Record the target set %NodeUsage.ToChannel $active ; Make sure the environment is sane NodeUsage.Sanity ; Get the usage if ($NodeUsage.GetUsage) { ; Store the global variables locally with the same name as the template functions var %gender %NodeUsage.Gender var %updated $asctime(%NodeUsage.LastUpdate,h:nn tt zz) var %rollover $asctime(%NodeUsage.Rollover,dd/mm/yyyy) var %rduation $duration($calc(%NodeUsage.Rollover - $ctime)) var %time_left $gettok(%rduation, $+(1-,$calc($numtok(%rduation,32)-1)),32) var %line_speed %NodeUsage.LineSpeed var %usage_used %NodeUsage.Used var %usage_limit %NodeUsage.Limit var %over_limit $calc(%usage_used - %usage_limit) var %limit_left $calc(%usage_limit - %usage_used) ; Don't ask me to explain this, it's 1 am. var %avg_left $round($calc(%limit_left / $round($calc(($ctime(01:01 %rollover) - $ctime)/24/60/60),0)),2) var %perc_used $round($calc((%usage_used / %usage_limit)*100),2) var %perc_left $round($calc((%limit_left / %usage_limit)*100),2) var %ex_rate %NodeUsage.ExcessRate var %ex_cost $calc(%ex_rate * %over_limit) ; Select an output format var %format $iif(%usage_used > %usage_limit, %NodeUsage.OverFormat, %NodeUsage.UnderFormat) ; Replace all the template variables var %output $replace(%format,*gender*,%gender,*updated*,%updated,*rollover*,%rollover,*time_left*,%time_left) %output = $replace(%output,*usage_used*,%usage_used,*usage_limit*,%usage_limit,*over_limit*,%over_limit) %output = $replace(%output,*limit_left*,%limit_left,*avg_left*,%avg_left,*line_speed*,%line_speed) %output = $replace(%output,*perc_left*,%perc_left,*perc_used*,%perc_used,*ex_rate*,%ex_rate,*ex_cost*,%ex_cost) ; Select an output method var %method $iif(%usage_used > %usage_limit, %NodeUsage.OverMethod, %NodeUsage.UnderMethod) ; Output if (%method == 1) { describe %NodeUsage.ToChannel %output } else { msg %NodeUsage.ToChannel %output } } } ; Display the setup dialog alias NodeUsage.Setup { dialog -m NodeUsage.Setup NodeUsage set %NodeUsage.Setup $true } ;*********************************************************** ; Menus ;*********************************************************** menu MenuBar { NodeUsage 3 .NodeUsage:/nodeusage .NodeUsage Setup:/nodeusage.setup .Unload:/unload -rs $script } menu Channel,Query,Chat { NodeUsage 3 .NodeUsage:/nodeusage .Advertise:/say I found NodeUsage 3 at http://fremnet.net/article/261/node-usage-3 } menu NickList { NodeUsage 3 .Tell use where to find:/msg $$1 I found NodeUsage 3 at http://fremnet.net/article/261/node-usage-3 } ;*********************************************************** ; Private Aliases ;*********************************************************** ; The initialization command alias -l NodeUsage.Init { NodeUsage.SSLnVersion echo 3 -as ................................. echo 3 -as . Node Usage V3.00 .............. echo 3 -as ..................... by Freman . echo 3 -as ................................. echo 3 -as .. Spam the current channel ..... echo 3 -as .............. with your usage .. echo 3 -as ................................. echo 3 -as ..... Setting default vars. ..... echo 3 -as ................................. set %NodeUsage.Username set %NodeUsage.Password set %NodeUsage.Gender his set %NodeUsage.GetSpeed 1 set %NodeUsage.UnderMethod 1 set %NodeUsage.OverMethod 1 set %NodeUsage.OverFormat is over *gender* *usage_limit* meg node usage limit by *over_limit* megs, *time_left* till reset. [Last Updated: *updated*] set %NodeUsage.UnderFormat has *time_left* to use the remaining *limit_left* of *gender* *usage_limit* meg Internode usage limit. Average daily to end of month: *avg_left* mb [Last Updated: *updated*] NodeUsage.Setup } ; Check out the environment, make sure it's sane - Wish I could find a simple way to progmatically adjust the SSL settings alias -l NodeUsage.Sanity { if (%NodeUsage.Setup != $true) { NodeUsage.RaiseError I have not been setup, please /reload the script - When prompted to run the initialization commands, choose yes } if (%NodeUsage.Username == $null) { NodeUsage.RaiseError No username set, please run /NodeUsage.Setup } if (%NodeUsage.Password == $null) { NodeUsage.RaiseError No username set, please run /NodeUsage.Setup } } ; Fires off a couple of sockets alias -l NodeUsage.GetUsage { NodeUsage.SSLnVersion if ($calc($ctime - %NodeUsage.LastUpdate) > 3600) { ; Only query for speed if we're expecting speed if (%NodeUsage.GetSpeed == 1) { sockopen -e NodeUsage.Speed customer-webtools-api.internode.on.net 443 } sockopen -e NodeUsage.Usage customer-webtools-api.internode.on.net 443 return $false } return $true } ; Make noise and fuss alias -l NodeUsage.RaiseError { if ($sock(NodeUsage).status == active) { sockclose NodeUsage } if (!$line($active,0)) { linesep -a } echo $color(info) -a * [NodeUsage] $1- linesep -a halt } ; More sanity checks :) alias -l NodeUsage.SSLnVersion { ; Check version if ($version < 6.17) { NodeUsage.RaiseError I am sorry, I need mIRC 6.17 or better } ; Check for SSL support if ($sslready != $true) { NodeUsage.RaiseError I need a SSL enabled mIRC see http://www.mirc.co.uk/ssl.html } } ;**************************************************** ; Events ;**************************************************** ; Executed as the script is loaded on *:LOAD: { NodeUsage.Init } ; Executed as the script is unloaded on *:UNLOAD: { unset %NodeUsage.* } on *:SOCKOPEN:NodeUsage.*: { if ($sockerr) { NodeUsage.RaiseError Socket Error ( $+ $sockerr $+ ) } sockwrite -tn $sockname POST /cgi-bin/padsl-usage HTTP/1.0 sockwrite -tn $sockname Host: customer-webtools-api.internode.on.net sockwrite -tn $sockname User-Agent: NodeUsage/3.00 (http://fremnet.net) sockwrite -tn $sockname Connection: close var %Content username= $+ %NodeUsage.Username $+ @internode.on.net&password= $+ %NodeUsage.Password %Content = %Content $+ $iif(.Speed isin $sockname, &speed=1) sockwrite -tn $sockname Content-length: $len(%Content) sockwrite -tn $sockname sockwrite -tn $sockname %Content sockwrite -tn $sockname } on *:SOCKREAD:NodeUsage.*: { if ($sockerr) { NodeUsage.RaiseError Socket Error ( $+ $sockerr $+ ) } var %data :nextread sockread %data if ($sockbr == 0) return if (%data == $null) %data = - if (%data == Authentication failed) { NodeUsage.RaiseError Authentication Failure - Check your username/password. Type /NodeUsage.Setup halt; } if ((.Speed isin $sockname) && $regex(%data, /^\d+(\.\d+)? [MK]?bits/)) { set %NodeUsage.LineSpeed %data sockclose $sockname } if ((.Usage isin $sockname) && $regex(%data, /^\d+(\.\d+)? \d+/)) { tokenize 32 %data set %NodeUsage.LastUpdate $ctime set %NodeUsage.Used $round($1,2) set %NodeUsage.Limit $2 set %NodeUsage.Rollover $ctime($3 01:01) set %NodeUsage.ExcessRate $4 sockclose $sockname } if ($sock(NodeUsage.*,0) == 0) { NodeUsage halt } if ($sock($sockname).open) { goto nextread } } on *:DIALOG:NodeUsage.Setup:init:0: { did -c $dname $iif(%NodeUsage.Gender == his, 11, 12) did -c $dname $iif(%NodeUsage.UnderMethod == 1, 14, 15) did -c $dname $iif(%NodeUsage.OverMethod == 1, 28, 29) if (%NodeUsage.GetSpeed == 1) { did -c $dname 13 } } on *:DIALOG:NodeUsage.Setup:sclick:17: { set %NodeUsage.Gender $iif($did($dname,11).state == 1, his, her) set %NodeUsage.GetSpeed $did($dname,13).state set %NodeUsage.UnderMethod $did($dname,14).state set %NodeUsage.OverMethod $did($dname,28).state } dialog -l NodeUsage { title "NodeUsage Version 3.00" size -1 -1 269 183 option dbu box "Output", 6, 4 42 262 123 box "Format Variables", 19, 5 118 259 43 box "Under Limit", 23, 5 49 259 34 box "Authentication", 1, 4 4 130 35 box "Information", 2, 136 4 130 35 text "Username:", 3, 9 14 30 8 text "Password:", 4, 9 26 30 8 text "Format:", 7, 9 71 30 9 text "Method:", 8, 9 59 30 8 edit %NodeUsage.Username, 9, 44 12 80 10, %NodeUsage.Username edit %NodeUsage.Password, 10, 44 24 80 10, pass %NodeUsage.Password check "Get the line speed", 13, 168 27 61 8 radio "Action (/me)", 14, 44 59 50 8, group radio "Say", 15, 99 59 50 8 edit %NodeUsage.UnderFormat, 16, 44 70 215 10, autohs %NodeUsage.UnderFormat button "Ok", 17, 233 167 32 12, ok button "Cancel", 18, 4 167 32 12, cancel text "*gender*", 20, 164 138 40 8 text "Gender:", 5, 141 14 30 8 radio "Male", 11, 175 13 30 8, group radio "Female", 12, 220 13 30 8 text "*usage_used*", 21, 11 128 40 8 text "*usage_limit*", 22, 11 138 40 8 box "Over Limit", 24, 5 84 259 34 text "Method:", 25, 9 94 30 8 text "Format:", 26, 9 106 30 9 edit %NodeUsage.OverFormat, 27, 44 105 215 10, autohs %NodeUsage.OverFormat radio "Action (/me)", 28, 44 94 50 8, group radio "Say", 29, 99 94 50 8 text "*limit_left*", 30, 62 128 40 8 text "*updated*", 31, 113 128 40 8 text "*rollover*", 32, 113 138 40 8 text "*line_speed*", 33, 164 128 40 8 text "*ex_rate*", 34, 215 128 40 8 text "*over_limit*", 35, 62 138 40 8 text "*time_left*", 36, 164 148 40 8 text "*perc_used*", 37, 11 148 40 8 text "*perc_left*", 38, 61 148 40 8 text "*avg_left*", 39, 113 148 40 8 text "*ex_cost*", 40, 215 138 40 8 } Commenting is closed for this article.
sexy script yet again another good one :D
— Snp Dec 4, 11:06 #
Good job dude!
— `Onyx Apr 7, 18:36 #