IdleRPG Info Script

By GrimReaper on May 10, 2010

Screenshots

This script I decided to make as I was playing IdleRPG.

It basically searches the IdleRPG site within the network you specify with the link and gather's the Data from the script

Syntax is: !IdleRPG

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; IdleRPG Stats Bot script         ;;
;; Made by GrimReaper               ;;
;; irc.SPUNet.org #SPUNet           ;;
;; irc.geekshed.net #hell           ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

alias -l IdleRPG {
  if (!$sock(IdleRPG)) {
    sockopen IdleRPG %IdleRPGsite 80
    sockmark IdleRPG $chan $chan $$1
  }
}

on *:sockopen:IdleRPG: {
  if ($sockerr) { msg $gettok($sock(IdleRPG).mark,1,32) Error: Couldn't connect to retrieve the specified data. }
  else {
    sockwrite -nt $sockname GET /playerview.php?player= $+ $gettok($sock(IdleRPG).mark,3,32) HTTP/1.0
    sockwrite -nt $sockname Host: %IdleRPGsite $+ $crlf $+ $crlf
  }
}

on *:sockread:IdleRPG: {
  sockread %IdleRPG
  if (<h1>Player Info</h1> isin %IdleRPG) && (<p><b>User:</b> isin %IdleRPG) {
    set -u9 %IdleRPGinfo $remove($htmlfree(%IdleRPG),Player,Info)
  }
  elseif (<b>Class:</b> isin %IdleRPG) {
    set -u9 %IdleRPGclass $htmlfree(%IdleRPG)
  }
  elseif (<b>Admin?:</b> isin %IdleRPG) {
    set -u9 %IdleRPGadmin $htmlfree(%IdleRPG)
  }
  elseif (<b>Level:</b> isin %IdleRPG) {
    set -u9 %IdleRPGlevel $htmlfree(%IdleRPG)
  }
  elseif (<b>Next level:</b> isin %IdleRPG) {
    set -u9 %IdleRPGnextlevel $htmlfree(%IdleRPG)
  }
  elseif (<b>Status:</b> isin %IdleRPG) {
    set -u9 %IdleRPGstatus $htmlfree(%IdleRPG)
  }
  elseif (<b>Total time idled:</b> isin %IdleRPG) {
    set -u9 %IdleRPGidled $htmlfree(%IdleRPG)
  }
  elseif (<b>Alignment:</b> isin %IdleRPG) {
    set -u9 %IdleRPGalignment $htmlfree(%IdleRPG)
  }
  elseif (<h1>Player Info</h1><h1>Error</h1> isin %IdleRPG) {
    set -u9 %IdleRPGerror Error: No such user.
  }
}

on *:sockclose:IdleRPG: {
  if (%IdleRPGerror != $null) { msg $gettok($sock(IdleRPG).mark,1,32) Error: %IdleRPGerror | HALT }
  elseif (%IdleRPGerror == $null) {
    msg $gettok($sock(IdleRPG).mark,1,32) IdleRPG Statistics:
    .timer 1 1 msg $gettok($sock(IdleRPG).mark,1,32) %IdleRPGinfo
    .timer 1 2 msg $gettok($sock(IdleRPG).mark,1,32) %IdleRPGclass
    .timer 1 3 msg $gettok($sock(IdleRPG).mark,1,32) %IdleRPGadmin
    .timer 1 4 msg $gettok($sock(IdleRPG).mark,1,32) %IdleRPGlevel
    .timer 1 5 msg $gettok($sock(IdleRPG).mark,1,32) %IdleRPGnextlevel
    .timer 1 6 msg $gettok($sock(IdleRPG).mark,1,32) %IdleRPGstatus
    .timer 1 7 msg $gettok($sock(IdleRPG).mark,1,32) %IdleRPGidled
    .timer 1 8 msg $gettok($sock(IdleRPG).mark,1,32) %IdleRPGalignment
  }
}

on *:TEXT:!IdleRPG*:#: {
  if (%idleprotection == on) { msg $chan Sorry $nick $+ , There is a search currently in place. }
  elseif (!$2) { msg $chan Incorrect Syntax used, Correct Syntax: !IdleRPG <Char Name> }
  elseif ($2) && (%idleprotection != on) {
    set -u10 %idleprotection on
    IdleRPG $2
  }
}

on *:LOAD: {
  set %IdleRPGsite $$?="Please enter the IdleRPG host, i.e. idlerpg.geekshed.net"
}
alias -l htmlfree { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, ) | return %x }

Comments

Sign in to comment.
GuitarMasterx7   -  May 11, 2010

off subject....
but if the dark side has cookies...

then the good side has brownies!

 Respond  
GrimReaper   -  May 10, 2010

@Napa182 That's certainly a much smaller version of it, but the reason I used the html tag version is that I'm not confident on using $regex just yet, Also I was going to use the html tag's and implement it into a Dialog script for those without a mIRC bot but a mIRC client for them.

 Respond  
Jethro   -  May 10, 2010

Also, using regex literally obliterates the use of html free alias. Sockets and regex are like a pair of inseparable couples.

 Respond  
napa182   -  May 10, 2010

nice but not all networks that play that have a stats site also the html tags may not be the same as the ones you used.

um for the site you used you can make it like this
just another way to go about it..

on $*:text:/^@IdleRPG\s(\S+)/iS:#: {
  if (!$hget(IdleRPG,say)) {
    if ($sock(IdleRPG)) sockclose IdleRPG
    msg # ***Looking up IdleRPG Statistics please wait....
    sockopen IdleRPG idlerpg.geekshed.net 80
    sockmark IdleRPG $+(/playerview.php?player=,$regml(1)) msg #
  }
}
on *:sockopen:IdleRPG: {
  sockwrite -nt $sockname GET $gettok($sock(IdleRPG).mark,1,32) HTTP/1.1
  sockwrite -nt $sockname Host: $+(idlerpg.geekshed.net,$str($crlf,2))
}
on *:sockread:IdleRPG: {
  var %IdleRPG | sockread %IdleRPG
  if ($regex(%IdleRPG,/<b>(.+?)<\/b>(.+?)<br \/>|<b>(No such user.)<\/b>/)) {
    hinc -mu10 IdleRPG say 1
    $iif($hget(IdleRPG,say) >= 1,$+(.,timerIdleRPG,$v1) 1 $calc($v1 +2) $&
      $gettok($sock(IdleRPG).mark,2-,32) $regml(1) $regml(2))
  }
}
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.