A fully featured Discord bot which supports managing games in a Mahjong Soul paid tournament lobby.
- See who is waiting in the lobby (
ms/list
) - Shuffle people into tables randomly and start games (
ms/shuffle
or clicking emojis) - Show the status of a fixed table layout and start the game with that layout once everyone is ready (
ms/tournament
), switch back to casual mode (ms/casual
) - Pause and unpause games in progress (
ms/pause
,ms/unpause
) and end them (ms/terminate
) - Display all tournament rule settings (
ms/rules
), ability to update select settings (ms/setrule
) - Track tournament scores using custom options (
ms/score
)
All without leaving the friendly confines of Discord!
- A tournament lobby. Check out the guide for how to purchase one.
- A Mahjong Soul account dedicated to the bot, which uses Twitter authentication.
- A Discord application and associated bot token.
- Bot is invited to a server of your choice.
- Python 3.8 with
pipenv
pipenv install
pipenv shell
cp config.env.example config.env
. Fill in all the fields that you can (see below for obtaining themahjong_soul_access_token
)./start.sh
It's recommended to run the actual bot in a screen.
- Install Websocket Frame Inspector.
- Load the Mahjong Soul Tournament Management page. (This is a nice one because it won't establish the websocket connection right away)
- Enable the Frame Inspector and put the window aside.
- Complete the Twitter authentication process.
- Back in the Frame Inspector, look for websocket payloads that are about 150-200 bytes.
- In the pipenv shell, use
scripts/mjs_decode 'PASTE PAYLOAD HERE'
against those payloads until you find the message that looks like this:
root:
1 <chunk> = ".lq.CustomizedContestManagerApi.oauth2LoginContestManager"
2 <chunk> = message:
1 <varint> = 10
2 <chunk> = "xxxxxxxx-yyyy-zzzz-aaaa-bbbbbbbbbbbb"
The last line will contain your access token, paste the value between the quotes as your access token in config.env