Created
July 12, 2020 13:57
-
-
Save schveiguy/7570d03bf1ae297cc331c863f881f1c1 to your computer and use it in GitHub Desktop.
Take a golf blitz team message and print out all the times the players joined.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import iopipe.bufpipe; | |
import iopipe.textpipe; | |
import iopipe.json.serialize; | |
import iopipe.json.parser; | |
import iopipe.json.dom; | |
import std.io; | |
import std.typecons; | |
import std.datetime; | |
import std.conv; | |
alias Json = JSONValue!(const(char)[]); | |
struct TeamMember | |
{ | |
@optional: | |
string displayName; | |
Json externalIds; | |
string id; | |
bool online; | |
Json scriptData; | |
double last_login; | |
Json pinpack; | |
double challenge_matchmaker_port; | |
double matchmaker_port; | |
Json slot1; | |
Json slot2; | |
Json slot3; | |
Json slot4; | |
Json ads_data; | |
string environment; | |
bool has_chosen_name; | |
string matchmaker; | |
Json daily_deals; | |
Json freepack;; | |
double is_buyer; | |
double token_time; | |
Json virtualGoods; | |
} | |
struct TeamMessage | |
{ | |
TeamMember[] members; | |
TeamMember owner; | |
string teamId; | |
string teamName; | |
string teamType; | |
} | |
void main() | |
{ | |
auto f = File(0).refCounted.bufd.assumeText; | |
auto parser = f.jsonTokenizer; | |
parser.next; | |
parser.parseTo("teams"); | |
parser.next; | |
auto tm = parser.deserialize!(TeamMessage); | |
import std.stdio; | |
foreach(ref member; tm.members) | |
{ | |
writefln("%s: id = %s, joined = %s", member.displayName, member.id, SysTime.fromUnixTime(member.id[0 .. 8].to!ulong(16))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment