disnog / netranger-bot

The custom bot for the Networking Discord server
https://networking-discord.github.io
3 stars 5 forks source link

Python: 3.6 | 3.7 | 3.8 Code style: black

network-ranger

The bot for the Networking Discord server

This bot is prepared to run either as a bare Python script, Heroku dyno, or Docker image. In this guide, the running configurations will be knows as 'direct', 'heroku' or docker respectively. All configuration options are therefore intended to be set via environment variables.

Usage

1) Generate a secret key (You must have the cryptography package installed.)

echo "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())" | python3                       1 ↵

2) Configure environment variables

If you're using Kubernetes, Docker, or Heroku, create file in the base of the project named .env with the contents: Replace all values as appropriate:

BOT_DESCRIPTION='[testing] The Networking Discord Bot'
COMMAND_PREFIX=^
EGGSROLE_NAME='!eggs'
GUILD_NAME=Networking-Dev
LOGCHANNEL_NAME=cnc
MEMBERCHANNEL_NAME=general
MEMBERROLE_NAME=Members
TOKEN=<YourBotsPrivateToken>
WELCOMECHANNEL_NAME=welcome
MIRRORCHANNEL_NAME=egg-qc
SMTP_USERNAME=mysmtpusername
SMTP_PASSWORD=mysmtppassword
SMTP_SERVER=in-v3.mailjet.com
SMTP_PORT=587
SMTP_FROMEMAIL=bot@domain.com
SECRETKEY=Secret key from Step 1
DB_HOST=mongodb.hostname
DB_PORT=27017
DB_NAME=network_ranger
DB_USER=<dbuser>
#DB_PASS=<dbpass>

If you're running this directly instead of as a container, you will need to load each one of these as an environment variable. Also, DB_PASS is commented as it should be loaded from your MongoDB secret if installed with Kubernetes. If not running with Kubernetes, you'll need to populate this.

3) Install and Run

A) Kubernetes

B) Docker

C) Heroku

A) heroku local
B) Heroku Cloud

D) Direct

  1. Install the requirements in requirements.txt:
    pip install -r requirements.txt
  2. Run the script:
    python3 network_ranger