mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2015
Posts: 7
R
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Mar 2015
Posts: 7
Hi, I have literally no idea how to do this, so if anybody could help, I would appreciate it.

I am wanting a world record command for my twitch bot, I know it's possible, I've seen other bots with this command.
The way this command would be used would be !wr (game) (category)

I believe the bots that have this command connect to speedrun.com to find the world records.

If you do this for me, I will love you, and if you don't, I understand, it's probably not a simple command.

Thanks.

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
It seems they have an API so it's not that hard, e.g:

http://www.speedrun.com/api_records.php?game=Grand%20Theft%20Auto:%20Vice%20City

You can paste that text into a JSON viewer to understand the structure (http://jsonviewer.stack.hu/)

You'll need to google a script called JSON for mIRC. If you search for JSON on this forum there should be many examples on how to use it.

Joined: Mar 2015
Posts: 7
R
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Mar 2015
Posts: 7
Ok, thanks!

I'm not too sure how to turn this into a command, can you help me just a little more? ._.

Last edited by revolutecbx; 09/07/15 01:05 AM.
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
ok, this is untested (there's probably something wrong), but after loading the mIRC JSON script you could do something like this


Code:
on *:text:!wr *:#:{
  jsonopen -du game http://www.speedrun.com/api_records.php?game= $+ $replace($2-,$chr(32), $chr(37) $+ 20)
  if ($json(game,$2-,Any $+ $chr(37),time) == $null) { 
  msg # No data found | return }
  else { 
    msg # $json(game,$2-,Any $+ $chr(37),player) $json(game,$2-,Any $+ $chr(37),time) $json(game,$2-,Any $+ $chr(37),video)   
  }
}

Joined: Mar 2015
Posts: 7
R
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Mar 2015
Posts: 7
Yeah, I think something's wrong with that, or I'm not using it correctly, thanks for the help, by the way smile .

Messing around with it right now, I'll let you know if I get it working.

It works, but there's a bit of a problem: It displays the time in seconds, I was wondering if there was a way to make it display the time like hours:minutes:seconds, that would be nice.

Also, this one isn't as much of a problem, and it doesn't need to be fixed, but, if I type !wr mm, for example, it uses the page for Majora's Mask, which doesn't work because... I'm not too sure how to explain it, so I'm going to post an image of what I mean. http://i.imgur.com/Mz7zHKz.png

Last edited by revolutecbx; 09/07/15 09:34 PM.
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
$duration() should convert to hours/minutes


For the other thing you need the first key in the array. AFAIK this JSON script doesn't have that functionality. Instead you would have to make a http request using sockets and then filter the name of the game from the response

Joined: Mar 2015
Posts: 7
R
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Mar 2015
Posts: 7
Thanks so much for your help! But I have one last question: Where do I put $duration()?

Nevermind, got it!

Thank you SOOOO much! <3

Last edited by revolutecbx; 10/07/15 12:27 AM.
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
use it on

$json(game,$2-,Any $+ $chr(37) $+ ,time)

but save that to a temp variable first

var %time = $json(game,$2-,Any $+ $chr(37) $+ ,time)
var %time = $duration(%time)


Link Copied to Clipboard