Skip to content

Hosting ClaireBot

Sidpatchy edited this page Aug 12, 2024 · 8 revisions

https://github.com/Sidpatchy/ClaireBot/wiki/Hosting-ClaireBot

ClaireBot is hosted for free by me, and will remain that way for the foreseeable future. However, you may wish to host your own instance of her. Doing so is relatively easy, you will just need to have some basic sysadmin skills.

As of ClaireBot v3.0.0-alpha.5, ClaireBot REQUIRES Java 17. ClaireData is built and tested against Java 17, however, Java 8 and 11 should still work.

The following sections are written in the order that makes things as simple as possible. I recommend following it.

Setting up Postgres

The following will demonstrate how to do this using Docker, if you aren't comfortable with that, you may find other resources.

Create and edit a file called docker-compose.yml

nano docker-compose.yml

Set the contents of the file to this, make sure you set a secure password (AND REMEMBER IT), you'll need it later.

version: "2.1"
services:
  clairedata-db:
    container_name: clairedata-db
    image: postgres
    restart: unless-stopped
    ports:
      - "5432:5432"
    environment:
      POSTGRES_DB: clairedb
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: examplePassword
    volumes:
      - clairedb-data:/var/lib/postgresql/data

volumes:
  clairedb-data:

Finally run

docker-compose up -d

Setting up ClaireData

First, you'll need to clone the ClaireData repository.

git clone https://github.com/Sidpatchy/ClaireData.git
cd ClaireData/

Next, you'll need to edit the password in the application.yml file. Be sure to change it to something secure! This is the password you set for Postgres.

nano src/main/resources/application.yml

Then, you'll need to edit the password in the SecurityConfiguration.java file. Again, change it to something secure!

nano src/main/java/com/sidpatchy/ClaireData/SecurityConfiguration.java

Finally, we'll need to build ClaireData. Do not worry about any tests failing.

./gradlew build

Assuming no errors, you will find a built version of ClaireData in build/libs/. Make sure you do not choose the file that ends with -plain.jar, if you're in doubt, choose the bigger file.

Setting up ClaireBot

Start by downloading the latest build of ClaireBot. Note that the link below is likely to be out of date, always check to see if it has changed.

wget https://ci.sidpatchy.com/repository/download/ClaireBot_Build/102:id/build/libs/ClaireBot-3.3.0-all.jar

Next, you'll need to run the bot once, the command should be along the lines of:

java -jar java -jar ClaireBot-3.0-all.jar

Then if we run ls, we'll get a list of files something like this

$ ls
ClaireBot-3.0-all.jar  config  logs

We're only interested in the file at config/config.yml

nano config/config.yml

You will need to fill in the following categories

# ----------------- MAIN CONFIG ----------------  
# General config options
  
# Discord bot token, get one at https://discord.com/developers/applications  
token:

Here, we just need to change the apiPath to our ClaireData instance, as well as the apiPassword to the password we set in the SecurityConfiguration.java file earlier.

ClaireData is hosted on http://127.0.0.1:8080 if you are just running this on one machine.

# --------------- DATABASE CONFIG --------------  
# Config options related to ClaireData.  
# https://github.com/Sidpatchy/ClaireData  
  
# ClaireData's login information  
apiPath: https://api.example.com/  
apiUser: clairedata  
apiPassword: examplePassword

As of ClaireBot 3.3.0, you will need to fill out the Zerfas section of the config, otherwise the bot will error when starting, and every time a message is sent in a server it is a member of. You will need to create a Zerfas emoji in a server that YOU own, and copy the server and emoji ID to the config file.

# ------------------- ZERFAS -------------------  
# https://en.wikipedia.org/wiki/Zerfas_(band)  
#  
# You will need to create a Zerfas emoji in a server YOU own, and copy the server and emoji ID here.  
# An emoji is provided here: https://github.com/Sidpatchy/ClaireBot/tree/main/img  
#  
# You can realistically modify this to work for anything you want. Just change the triggers under 'zerfas'  
  
# List of things to react to with the Zerfas emote  
zerfas:  
  - "YOU NEVER WIN"  
  - "THE SWEETEST PART"  
  - "I DON'T UNDERSTAND"  
  - "I NEED IT HIGHER"  
  - "STONEY WELLITZ"  
  - "HOPE"  
  - "FOOL'S PARADE"  
  - "THE PIPER"  
  - "CERTAIN KIND OF LADY"  
  - "SHAKE UP YOUR MIND"  
  - "ZERFAS"  
  - "GOOD MUSIC"  
  
zerfas_emoji_server_id:  
zerfas_emoji_id:

Additionally, ClaireBot supports sharding, if you're in doubt, don't touch this.

Just change the current shard, and total shards accordingly.

# ----------------- SHARD CONFIG ---------------  
# It is assumed that only one shard will be running by default.  
# You probably don't need to change this.  
  
# The shard the bot should log in to  
current_shard: 0  
  
# The total number of shards.  
total_shards: 1

Putting it all together

Now that we have ClaireBot and ClaireData setup, we should be able to start everything.

I like to use Screen but there are a number of options you could use.

Open a screen for ClaireData and start it.

screen -S ClaireData # will open a new screen named ClaireData
java -jar ClaireData-0.0.1-SNAPSHOT.jar

Next, we'll need to open another Screen for ClaireBot.

screen -S ClaireBot
java -jar java -jar ClaireBot-3.0-all.jar

Assuming you've done everything correctly, ClaireBot should now be up and running. Go ahead and run a command to test the database, if there are no errors, you're all set!

Clone this wiki locally