Getting Started (For Developers)
This will have everything needed in order to get started with development for Rin.
Requirements
To get started, you'll need these things installed:
- Git
- Python 3.10
- Pipenv
- WSL (If working on Windows)
- Discord Account + Discord App
Installing Dependencies
Getting the environment set up for the bot is a kinda complex process. Rin now uses Uvloop, which is a drop-in replacement for Asyncio and is just as fast as Node.js. If you want to get set up, here are the instructions to do so:
Windows
Install WSL2. Pick your distro of choice. In this example, we will use Ubuntu 22.04
Install the suggested build dependencies for pyenv.
sudo apt-get update; sudo apt-get install make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev python3.10-dev gitInstall Pyenv. Also make sure to follow the instructions here
curl https://pyenv.run | bash
pyenv update
pyenv install 3.10.6
pyenv global 3.10.6
pyenv rehashRestart your shell (make sure you have added it to your path and configured it either in your
.zshrc
, or.bashrc
files)exec "$SHELL"
Fork and clone the repo
git clone https://github.com/[username]/Rin.git && cd Rin
Run Make to create the venv and install dependencies
make dev-setup
Linux
Ubuntu
Install the suggested build dependencies for pyenv.
sudo apt-get update; sudo apt-get install make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev python3.10-dev gitInstall Pyenv. Also make sure to follow the instructions here
curl https://pyenv.run | bash
pyenv update
pyenv install 3.10.6
pyenv global 3.10.6
pyenv rehashRestart your shell (make sure you have added it to your path and configured it either in your
.zshrc
, or.bashrc
files)exec "$SHELL"
Fork and clone the repo
git clone https://github.com/[username]/Rin.git && cd Rin
Run Make to create the venv and install dependencies
make dev-setup
OpenSUSE
Install the suggested build dependencies for pyenv.
sudo zypper install gcc automake bzip2 libbz2-devel xz xz-devel openssl-devel ncurses-devel \
readline-devel zlib-devel tk-devel libffi-devel sqlite3-devel python310-develInstall Pyenv. Also make sure to follow the instructions here
curl https://pyenv.run | bash
pyenv update
pyenv install 3.10.6
pyenv global 3.10.6
pyenv rehashRestart your shell (make sure you have added it to your path and configured it either in your
.zshrc
, or.bashrc
files)exec "$SHELL"
Fork and clone the repo
git clone https://github.com/[username]/Rin.git && cd Rin
Run Make to create the venv and install dependencies
make dev-setup
Fedora/CentOS
Install the suggested build dependencies for pyenv
Fedora 22 and above:
sudo dnf install make gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel xz-devel python-devel git curl
CentOS or Fedora 22 and below:
sudo yum install gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel xz-devel python-devel git curl
Install Pyenv. Also make sure to follow the instructions here
curl https://pyenv.run | bash
pyenv update
pyenv install 3.10.6
pyenv global 3.10.6
pyenv rehashRestart your shell (make sure you have added it to your path and configured it either in your
.zshrc
, or.bashrc
files)exec "$SHELL"
Fork and clone the repo
git clone https://github.com/[username]/Rin.git && cd Rin
Run Make to create the venv and install dependencies
make dev-setup
Arch/Manjaro
Install the suggested build dependencies for pyenv
sudo pacman -S --needed base-devel openssl zlib xz tk python libffi
Install Pyenv. Also make sure to follow the instructions here
curl https://pyenv.run | bash
pyenv update
pyenv install 3.10.6
pyenv global 3.10.6
pyenv rehashRestart your shell (make sure you have added it to your path and configured it either in your
.zshrc
, or.bashrc
files)exec "$SHELL"
Fork and clone the repo
git clone https://github.com/[username]/Rin.git && cd Rin
Run Make to create the venv and install dependencies
make dev-setup
MacOS
Install Xcode Command Line Tools (
xcode-select --install
) and HomebrewInstall the suggested build dependencies for pyenv
brew install openssl readline sqlite3 xz zlib tcl-tk git curl make
Install Pyenv via Homebrew
brew update
brew install pyenvInstall Python
pyenv update
pyenv install 3.10.6
pyenv global 3.10.6
pyenv rehashFollow the rest of the steps, starting on Set Up Your shell Environment For Pyenv
Fork and clone the repo
git clone https://github.com/[username]/Rin.git && cd Rin
Run Make to create the venv and install dependencies
make dev-setup
Getting Started
Getting the Discord Bot
First things first, you'll more than likely need a dev bot to run Rin. Luckily you'll find the steps below to help you on that
- Create the app that will be needed for the bot. Once done, you should see the page as shown above
- Now head done to the bot section, and click on the button that says "Add Bot".
- You'll see a pop-up that asks you if you want to create the bot.
- Make sure to have all 3 of the buttons enabled. Rin will need all 3 of them to work.
- You'll see a page just like the one above. We'll need access the the token for the bot, and the only way to do it is to reset the token.
- Allow for the token to be reset. Note that if your account is hooked up with 2FA, it will ask you to enter your 2FA code. Go to your authenticator app and enter the code from the app.
Now click on the copy button and copy the token
Head back into the root directory of the repo, and run this command:
make init BOT_TOKEN="[token]"
This will create a
.env
file and add the token into it.
Developing Rin
Once you have the discord bot up, there's a few things that needs to be done before development can begin.
Follow the steps in Installing Dependencies to get all of the dependencies installed.
Now create a shell that pipenv needs. Run the following command:
pipenv shell
To run Rin, run the following command:
make
You could also run this command, which does the same thing:
make run
To exit out of Rin, hit Ctrl + C to kill the process.
Things to keep in mind
Make sure to always keep this in mind: Always add exception handling for Rin. And make sure it is done correctly. A poor example would be this:
try:
async with aiohttp.ClientSession(json_serialize=ujson.dumps) as session:
async with session.get(url) as resp:
data = await resp.content.read()
dataMain = parser.parse(data, recursive=True)
print(dataMain["data"]["children"][0]["data"]["title"]) # Doesn't exist within JSON data
except Exception as e:
await ctx.respond(e)
But rather actually specify the exception that you want to handle.
try:
async with aiohttp.ClientSession(json_serialize=ujson.dumps) as session:
async with session.get(url) as resp:
data = await resp.content.read()
dataMain = parser.parse(data, recursive=True)
print(dataMain["data"]["children"][0]["data"]["title"]) # Doesn't exist within JSON data
except ValueError:
await ctx.respond("That item doesn't exist! Please try again")
API Keys
Some of the API's that Rin uses requires an API key. Here's the list of all of the services that require one:
- Twitter (requires bearer token, make sure that the bearer token supports Twitter API V2)
- Hypixel
- *DeviantArt (Use the DA-Token-Refresher script in production for refreshing tokens)
- Tenor (Use API V2)
- First FRC
- Discord.bots.gg
- Top.gg
- GitHub
- YouTube
- Blue Alliance
- Twitch
*Note: DeviantArt is officially unsupported due to the process of handling the access tokens and refreshing them.
Docker Tagging Styles
Rin does have in fact a style of tagging docker images. Here it is:
- If deploying to master or production (NOTE: DO NOT DEPLOY TO PRODUCTION UNLESS IT IS FULLY TESTED AND APPROVED):
<image>:<github_release_tag>
- If deploying to dev:
<image>:<next_minor_version>-dev-<short_commit_sha>