MJSoul Scraping Bot
-
You will need:
nodejs
,npm
. Install them however you need. -
Install the necessary packages via
npm install
. -
Create your own discord bot via the discord developer portal and obtain its Auth Token. Find the channel ID for the discord channel you want the bot to post in, and add both of these values to your
config.secret.js
file. -
Create and login to a dummy Majsoul account via Twitter (must be via Twitter). Open up the developer tools in Google Chrome. Go to the Network tab and refresh the page.
-
Filter only for WS requests, and look at the first binary message. It should have a message like:
....lq.Lobby.oauth2Auth... jibberish..numbers
The first set of jibberish is your oauth token, and the numbers at the end is your user id. Add both of those values to yourconfig.secret.js
file. -
Find the tournament ID. This can be done by joining your tournament via the dummy majsoul account, and then looking for this websocket message: Then, enter the last 6 values (in this case,
08b417
) into the hex textbox of this decoder: https://protogen.marcgravell.com/decode. Add this decoded value (in this case, 2996) to yourconfig.secret.js
file. -
Rename
config.secret.js
toconfig.js
-
[NEW]: Replace the
liqi.json
file in thenode_modules/mjsoul
directory with theliqi.json
file in the main directory. -
Run
node main.js
in your favourite terminal.
!bot_ping
: Healthcheck you can use to make sure that the bot is connected to discord.!game_list X
: Fetches the UUIDs of the last X games. If X is empty, the default value of UUIDs fetched is 5.!parse_hanchan UUID
: Parses the hanchan with that UUID, and saves the parsed JSON into the logs directory.
The JSON is formatted according to this schema. Feel free to create a batch process or extend the discord bot to parse this JSON and power the scoring system for a website.