mIRC Home    About    Download    Register    News    Help

Print Thread
#258778 28/08/16 02:38 PM
Joined: Mar 2016
Posts: 21
P
pykolas Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Mar 2016
Posts: 21
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

pykolas #258779 28/08/16 04:07 PM
Joined: Jul 2006
Posts: 4,146
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,146
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.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #258780 28/08/16 04:32 PM
Joined: Mar 2016
Posts: 21
P
pykolas Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Mar 2016
Posts: 21
What's the difference between sockets and json?

pykolas #258781 28/08/16 04:39 PM
Joined: Mar 2016
Posts: 21
P
pykolas Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Mar 2016
Posts: 21
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%.

pykolas #258785 28/08/16 05:59 PM
Joined: Jul 2006
Posts: 4,146
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,146
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.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
pykolas #258787 29/08/16 02:47 PM
Joined: Mar 2016
Posts: 21
P
pykolas Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Mar 2016
Posts: 21
Thank you smile


Link Copied to Clipboard