Longhorn-Riichi / Ronhorn

Longhorn Riichi's club bot. Includes global commands that provide mahjong utilities.
https://longhornriichi.com/ronhorn/
MIT License
7 stars 1 forks source link
mahjong mahjong-algorithm mahjongsoul tenhou

Ronhorn

Ronhorn is Longhorn Riichi's Discord Bot, which supports two categories of slash commands:

  1. commands specific to Longhorn Riichi's club operations (/register, /enter_score, etc.)
  2. commands that provide utilities for online mahjong games like Mahjong Soul and Tenhou (/skill, /parse, etc.)

The documentation for the Discord slash commands can be found here

It also has a passive component that automatically tracks and records online games played in the club's Mahjong Soul lobbies, which is a more advanced version of that of the UvUManager.

Repository Structure:

Setting up the bot

First, cp config.template.env config.env.

Discord Stuff

  1. set up a bot account on Discord's developer portal (New Application).
    • (SETTINGS -> Bot) Privileged Gateway Intents: SERVER MEMBERS INTENT AND MESSAGE CONTENT INTENT
  2. invite the bot to the respective servers. You can use the developer portal's OAuth2 URL Generator (SETTINGS -> OAuth2 -> URL Generator):
    • Scopes: bot
    • Bot Permissions: Send Messages, Manage Messages, Use External Emojis (and more as we add more functionalities)
  3. fill in the Discord Stuff section of config.env. The bot token can be obtained through (SETTINGS -> Bot [-> Reset Token])

    Google Sheets Stuff

  4. set up a Google Cloud project. Enable Google Sheets API access, and make a service account. Generate a JSON key for that service account and save it as gs_service_account.json in the root directory
  5. make a suitable Google Spreadsheet (example) and share the Spreadsheet with that service account.
  6. fill in the Google Sheets Stuff section of config.env

    Mahjong Soul Stuff

  7. fill in the Mahjong Soul Stuff section of config.env

    Server Lists

    Make an injustice_servers.json in the root directory, with <server_name>: <server_ID> pairs. The <server_name> is for record-keeping only. Only servers whose <server_ID> is specified here will have the /injustice command available. Example:

    {
    "Longhorn Riichi": "111111111111111111",
    "The Riichi Mahjong Association (UT Dallas)": "111111111111111111",
    "Riichi Nomi": "111111111111111111"
    }

Similarly, make a slash_commands_servers.json in the root directory, for the servers that want the slash commands that are not exclusive to Longhorn Riichi (excluding /injustice).

{
  "Longhorn Riichi": "111111111111111111",
  "The Riichi Mahjong Association (UT Dallas)": "111111111111111111",
  "Main Mahjong Server": "111111111111111111",
  "Riichi Nomi": "111111111111111111"
}

Running the bot

  1. in a Unix shell:

    pipenv install
    pipenv shell
    ./start.sh
  2. in the relevant Discord server: run rh/sync to sync the slash commands for that server (rh/ is the regular command prefix).

Relevant Links (References)