Code / mIRC / WhatPulse Statistics

  1. ; WhatPulse Information Script for mIRC 6.X
  2. ; Written by Scott Wilcox <sc0tt@x0f.org>
  3. ; Thanks goto Splodgey, wasted.
  4. ;
  5. ; http://nixbox.org
  6. ;
  7. ; PLEASE NOTE:
  8. ;
  9. ; For this script to work, you need to enable your
  10. ; stats to be generated on the whatpulse server. To
  11. ; do this, login to the WhatPulse site, goto your
  12. ; option and check "Generate XML statistics (webapi)"
  13. ; you will then need to wait until 3:00, 9:00, 15:00
  14. ; or 21:00 GMT has passed to update your statistics.
  15.  
  16. on *:start: {
  17.   %old = %wp_userid
  18.   unset %wp_
  19.   %wp_userid = %old
  20.   wp_update
  21. }
  22.  
  23. alias">alias wp_update {
  24.   if (%wp_userid !isnum) {
  25.     set %wp_userid $$?="Enter Your WhatPulse User ID:"
  26.     echo $colour(info text) -a *** WhatPulse User ID Set, please re-run /wp_update
  27.     return
  28.   }
  29.   ; Check to see if socket is already in use.
  30.   if ($sock(wp_socket)) {
  31.     ; Return error message if so
  32.     echo $colour(info text) -a *** WhatPulse is already updating stats, please wait.
  33.     return
  34.   }
  35.  
  36.   ; Socket not in use, echo out updating message
  37.   echo $colour(info text) -a *** WhatPulse updating stats
  38.  
  39.   ; If the whatpulse server ever changes, this will
  40.   ; need to be updated too.
  41.   sockopen wp_socket whatpulse.org 80
  42. }
  43.  
  44. on *:sockopen:wp_socket: {
  45.   if ($sockerr) {
  46.     echo $colour(info text) *** error $sockerr when downloading
  47.     return
  48.   }
  49.   unset %downloadlength %downloadready
  50.   sockwrite -n $sockname GET /api/users/ $+ %wp_userid $+ .xml HTTP/1.0
  51.   sockwrite -n $sockname Accept: */*
  52.   sockwrite -n $sockname Host: whatpulse.org
  53.   sockwrite -n $sockname User-Agent: http://sc0tt.ca v1.0
  54.   sockwrite -n $sockname
  55. }
  56.  
  57. on *:sockread:wp_socket:{
  58.   if (%wp_downloadready != 1) {
  59.     var %header
  60.     sockread %header
  61.     while ($sockbr) {
  62.       if (Content-length: * iswm %header) {
  63.         %wp_downloadlength = $gettok(%header,2,32)
  64.       }
  65.       elseif (* !iswm %header) {
  66.         %wp_downloadready = 1
  67.         %wp_downloadoffset = $sock($sockname).rcvd
  68.         break
  69.       }
  70.       sockread %header
  71.     }
  72.   }
  73.   sockread %c
  74.   while ($sockbr) {
  75.     set $+(% $+ wp_,$gettok($gettok(%c,2,60),1,62)) $gettok($gettok(%c,2,62),1,60)
  76.     sockread 4096 %c
  77.   }
  78.   set %wp_lastupdated $ctime
  79. }
  80.  
  81. on *:sockclose:wp_socket:{
  82.   ; Socket has been closed, the stats were updated.
  83.   echo $colour(info text) -a *** WhatPulse stats finished updating ( $+ %wp_downloadlength bytes downloaded).
  84. }
  85.  
  86. alias">alias wp_show {
  87.   ; %wp_GeneratedTime 2005-03-28 21:00:20
  88.   ; %wp_UserID 4152
  89.   ; %wp_AccountName sc0tt
  90.   ; %wp_Country United Kingdom
  91.   ; %wp_DateJoined 2004-01-11
  92.   ; %wp_Homepage http://sc0tt.ca
  93.   ; %wp_LastPulse 2005-03-25 00:50:09
  94.   ; %wp_Pulses 105
  95.   ; %wp_TotalKeyCount 172224
  96.   ; %wp_TotalMouseClicks 28750
  97.   ; %wp_AvKeysPerPulse 1640
  98.   ; %wp_AvClicksPerPulse 274
  99.   ; %wp_AvKPS 0
  100.   ; %wp_AvCPS 0
  101.   ; %wp_Rank 30593
  102.   ; %wp_TeamID 2818
  103.   ; %wp_TeamName Mac
  104.   ; %wp_TeamMembers 6
  105.   ; %wp_TeamKeys 6679753
  106.   ; %wp_TeamClicks 826313
  107.   ; %wp_TeamDescription The Mac Whatpulse Team
  108.   ; %wp_TeamDateFormed 20 October 2004 at 17:25:57
  109.   ; %wp_RankInTeam 5
  110.   ; %wp_lastupdated 1112042573
  111.   ;
  112.   ; The list above shows the variables that are set when you
  113.   ; update the script. They are set globally, and you can use
  114.   ; them in any way that you want to.
  115.   ; For this example, I just used a /say
  116.   //say  $+ %wp_AccountName $+ : [tkc / tmc / rank: %wp_TotalKeyCount / %wp_TotalMouseClicks / %wp_Rank $+ $chr(93) [lp: %wp_LastPulse $+ $chr(93) [avkps: %wp_AvKPS $+ $chr(93) [dj: %wp_DateJoined $+ $chr(93) [Country: %wp_Country $+ $chr(93) [hp: %wp_Homepage $+ $chr(93) [team: %wp_TeamName $+ $chr(93) $+ 
  117. }
  118.  
  119. ; Simple menus.
  120. menu channel,nicklist,nicklist {
  121.   WhatPulse Stats
  122.   .Update: wp_update
  123.   .Show in # $+ : wp_show
  124. }
  125.  

Download as Text : January 6th, 2009