Skip to content
/ Josix Public

A discord bot written in Python for general purpose, fun, stats and more

License

Notifications You must be signed in to change notification settings

ClubNix/Josix

Repository files navigation

icon_josix
Josix by Club*Nix

python

What is Josix

Josix is a discord bot written with py-cord. Mostly for fun its goal is at first just general purpose for the server of the Club*Nix (join here) like :

  • 👋 Custom welcome message
  • ⚙️ Reaction role
  • 📖 Logger
  • 💾 Postgre database backup
  • 🎂 Birthday reminder
  • 📈 XP System
  • 💰 Commands to use our food system API, Monix
  • 🎮 Board games such as : tic-tac-toe, othello, connect-4 and more
  • 🧠 Private jokes register
  • 😂 Joke generator
  • 🔓 Log system (basic log + error log) with custom display with error formating

Install and lauch

  • Clone the repository :

  • Create a folder in the root directory of the project (data is the default name) and add the following files :

    • backup.sql
    • daily_backup.sql
    • daily_backup.sql.old
    • askip.json
    • logs folder with :
      • josixout.log
      • josixerr.log
  • Add your informations :

    • Create a .env file for the docker-compose.yml with these informations (default values given):
JOSIX_IP=bot_ip (192.168.1.2)
ADMINER_IP=adminer_ip (192.168.1.3)
DB_IP=database_ip (192.168.1.4)
DRIVER=bridge
PARENT=ens18
SUBNET=subnet_of_services (192.168.1.0/24)
GATEWAY=gateway_of_subnet (192.168.1.1)
  • Create a .env.db for all the secret informations about the database :
POSTGRES_USER=root
POSTGRES_PASSWORD=root
POSTGRES_DB=your_db
PG_USER=root
  • Create a .env.dev file for all the secret informations for the bot :
DISCORD=discord_bot_token
JOKES=blagues_api_token
DB_NAME=database_name
DB_USER=database_user
DB_PASSWORD=database_user
HOST=database_host
MONIX_LOG=bot_monix_username (only for us)
MONIX_PASSWORD=bot_monix_password (only for us)
HOME=home_directory (./)
LOGS=logs_directory (logs/)

The JOKES field for blagues_api token is not required to launch the bot. It's used for the joke command (french jokes only).
The HOME and LOGS fields are here to get logs and get nothing in your terminal
No need to give MONIX_LOG and MONIX_PASSWORD, they are meant to be used only by Club*Nix.

  • Edit the config.json file to give your informations.

    • The links field is here to give a list of your personal links (or whatever you want), it will work as an hypertext.
    • The tags field is here to automatically create "open" and "close" tags for the forum channel. DO NOT edit the names open and close, just edit their content.
    • The report_channel field will contain the ID of the channel where you want to receive database connection check error
  • Add your own private jokes :

    • If not already done, create askip.json (if you want to change the name you have to change it in the fun.py file)
    • Fill it with your private jokes like this :
{
	"category or one's name" : {
		"joke's name" : "fill with your private joke",
		"another" : "another joke",
		"..." : "..."
	},

	"..." : {
		"joke" : "..."
	}
}
  • Add some inserts in initialization-scripts/3-data-josix.sql to have auto-insert when creating the volumes.

  • Check docker-compose.yml to be sure that the volumes are well-linked.

  • Run the bot :

    • sudo docker-compose build Build the bot (if the code have been modified).

    • sudo docker-compose up Launch the whole project.

    • Access to the adminer page to manage your database at adminer_ip:8080. Then log with :

      • PostgreSQL
      • db (by default)
      • postgres_user
      • user_password
      • postgres_db

Warning

If you are launching the bot without docker, you can get an error on installing psycopg2 with pip3 install -r requirements.txt, enter the following commands :

  • pip3 install psycopg2-binary
  • sudo apt install libpq-dev python3-dev

And then you can retry to install psycopg2
Disable the monix extension by deleting cogs/monix.py or by renaming the python file with an _ before it like this : _monix.py.

All the commands of the extension owner can be executed by the administrators of the server. It has been made like this because our organization has a special case but it can leads to security issues with your bot if you use it cross-server. To avoid this, make sure to edit the cog_check method in the owner.py file.
e.g. remove or ctx.author.guild_permissions.administrator if you want the commands to be executed only by the bot's owner. Also, the same thing applies for displaying the owner commands with the help command. Change the condition, according to your will.

License

Josix is under the Apache 2-0 license

About

A discord bot written in Python for general purpose, fun, stats and more

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published