mIRC Homepage
Posted By: pykolas Java and mirc - 28/08/16 02:38 PM
Okay, so I have server which gives me information, I want to pull that information with mirc and output it on twitch. I am total 0 with this stuff. Maybe someone can give me an example of simple script which pulls one data from random database and outputs it on twitch? Also, would be good redirection to more info and learning material about this stuff. Knowledge is power smile
Posted By: Wims Re: Java and mirc - 28/08/16 04:07 PM
What is the output format? If it's plain text, you would just use socket in mIRC, if it's JSON, there is a JSON snippet here

http://en.wikichip.org/wiki/mirc is a good starting point, with http://en.wikichip.org/wiki/mirc/sockets/tcp specifically to get data from http servers, the examples might not be working anymore, but the logic behind them stay.
Posted By: pykolas Re: Java and mirc - 28/08/16 04:32 PM
What's the difference between sockets and json?
Posted By: pykolas Re: Java and mirc - 28/08/16 04:39 PM
Btw, this is what I have on my php:
Quote:
<?php
ini_set("allow_url_fopen", 1);
$username = $_GET["u"];
$url = "https://osu.ppy.sh/api/get_user?u=" . $username . "&k=mysecretkey";
$json = file_get_contents($url);
$result = json_decode($json, true);
$accuracy = $result[0]["accuracy"];
$worldrank = $result[0]["pp_rank"];
$name = $result[0]["username"];
$pp = $result[0]["pp_raw"];
$acc = round($accuracy, 2);
$wrank = number_format($worldrank);
if ($pp > 0) {
print("Stats for " . $name . ": " . $pp . "pp, rank: #" . $wrank . ", acc: " . $acc . "%.");
}
else {
print("An error occured please check your inserted data.");
}
?>

Input would be: !stat "nick"
Output would be: Stats for "nick": xxx.xxpp, rank: #x,xxx, acc: xx.xx%.
Posted By: Wims Re: Java and mirc - 28/08/16 05:59 PM
JSON is a format, extracting data from JSON using something else than a JSON parser is a bad idea, and writting a JSON parser is not trivial (notice how you have some JSON related thing in the php code).

But what you are outputing is plain text, so just use socket.
Posted By: pykolas Re: Java and mirc - 29/08/16 02:47 PM
Thank you smile
© mIRC Discussion Forums