Contributing
We are glad that you're willing to contribute to this project. We are usually very lenient and relaxed with the submissions of PRs, and Issues reports. But there are some stuff that you need to know before contributing.
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
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
Naming Conventions
For Rin, the main naming convention is camelCasing. Python's naming convention is snake_casing, but I personally find it easier to use camelCasing. All classes for any cogs should be in PascalCase. And yes camelCase all variables. You'll get used to it...
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>
Pull Requests and Commits
You have 2 option: Fork the repo and make a pull request back into the main one, or commit to the branch directly. Option 2 is preferred. If it's not for any fixes including any hotfixes, please submit it to the dev branch, not the master branch
Formatting
Rin uses pre-commit hooks to format all of the code. Make sure run git add --all
before committing to add all of the files. And if you get stuck in a loop, (mainly if black or isort constantly keep on formatting for no reason), append the --no-verify
flag to the command to commit it directly.
Issue and Feature Requests Reports
If there is an issue or a feature you want to be added, use the built-in GitHub issue tracker. Though a system like Jira could be used, it would be more efficient to just use the issue tracker that GitHub provides.
- If submitting a issue report, follow the template. Duplicates will not receive support
- If submitting a feature request, follow the template as well. As with issue reports, duplicate requests will not receive support
Releasing Tags
In order to automate the release system, you have to make sure that in order to use it, the git commit message must be done correctly. Only use this if there is a new update that is ready to be released. Rin uses SemVer as the standard for versioning. Here's a table that should help with explaining this:
Type of Release, Update, or Patch | Example |
---|---|
Major Release | Release: v2 |
Minor Release | Update: v2.5.0 |
Patch Release | Fix: v2.5.1 |
Git Commit StyleGuides
- If updating any other files that aren't project files or not important (stuff like README.md, contributing.md, etc), add the [skip ci] label in the front
- With each new commit, the message should be more or less describing the changes. Please don't write useless commit messages...
- If releasing tags, have it in this style.
Release: [insert what changed here]
,Update: [insert what changed here]
, andFix: [insert what changed here]
. Release is a major release. This means it bumps from 1.0.0 to 2.0.0. Minor means it bumps up the version from 1.4 to 1.5 for example. And fix just applies a patch, which would be 1.4.1 to 1.4.2.