Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
38 changes: 37 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@
# Discord Bot config - Required
DISCORD_TOKEN=
DISCORD_PUBLIC_KEY=

# Discord Server Config - Required
DISCORD_GUILD_ID=
DISCORD_CHANNEL_ID=
DISCORD_UPDATE_ROLE_ID=
## Default=true
DISCORD_SHOULD_CROSSPOST=

# Statuspage Config - Required
STATUSPAGE_API_KEY=
STATUSPAGE_PAGE_ID=
## Default=status.ticketsbot.cloud
STATUSPAGE_URL=

# Discord gateway port -Required
## Default=8080
SERVER_ADDR=

# Database Config - Required
## Leave Vars empty when using Database included in the provided docker-compose.yaml file!
## Default=postgres://postgres:${DATABASE_PASSWORD:-null}@postgres-statusbot:5432/postgres?sslmode=disable
DATABASE_URI=
## Default=null
DATABASE_PASSWORD=



# Optional Configurations:

# Daemon Config - optional
## Default=false
DAEMON_ENABLED=
## Default=30s
DAEMON_FREQUENCY=
## Default=30m
DAEMON_EXECUTION_TIMEOUT=


DATABASE_URI=postgres://postgres:postgres@localhost/postgres?sslmode=disable
# Debug Config - ONLY TOUCH THESE WHEN YOU KNOW WHAT YOUR DOING!
## Default=false
JSON_LOGS=
## Default=info
LOG_LEVEL=
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,30 @@ Status Updates is a backend service that keeps your Discord community informed b

---

## Installation
# Installation

## Using Docker


1. **Clone the repository:**
```sh
git clone https://github.com/TicketsBot-cloud/status-updates.git
cd status-updates
```
2. **Create a .env file by copying the provided [.env.example](./.env.example) file.**
Fill out all Env Variables in the sections that are Required.
3. **Start the Bot**
Run the following command in the directory the Bot's files were copied to:
`docker compose up -d`
4. **Set the Interaction Endpoint URL**
Go to the [Discord Developer Portal](https://discord.com/developers/applications) and click on the Application you made for this bot.
Set the Interaction Ednpoint URL to your Proxied domain with `/interactions` added behind it. (e.g. `https://{YOUR-CUSTOM-DOMAIN}/interactions`)
* You will need to proxy the port you set as your SERVER_ADDR (e.g. 8080) to a Publicly Accessible URL.
* Replace `{YOUR-CUSTOM-DOMAIN}` with your proxied URL (e.g. `gateway.example.com`)


## Manual


1. **Clone the repository:**
```sh
Expand All @@ -67,7 +90,7 @@ Status Updates is a backend service that keeps your Discord community informed b
go build -o status-updates ./cmd/status-updates
```

## Configuration
### Configuration

Configuration is managed via environment variables or a config file. See `internal/config/config.go` for all options.

Expand All @@ -85,7 +108,7 @@ STATUSPAGE_PAGE_ID=statuspage_page_id
DATABASE_URI=postgres://postgres:postgres@localhost/postgres?sslmode=disable
```

## Usage
### Usage

To run the service locally:
```sh
Expand Down
54 changes: 54 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
services:
statuspages_bot:
build:
dockerfile: './.Dockerfile'
environment:
DAEMON_ENABLED: ${DAMEON_ENABLED:-false}
DAEMON_FREQUENCY: ${DAEMON_FREQUENCY:-30s}
DAEMON_EXECUTION_TIMEOUT: ${DAEMON_EXECUTION_TIMEOUT:-30m}
DISCORD_TOKEN: ${DISCORD_TOKEN}
DISCORD_PUBLIC_KEY: ${DISCORD_PUBLIC_KEY}
DISCORD_GUILD_ID: ${DISCORD_GUILD_ID}
DISCORD_CHANNEL_ID: ${DISCORD_CHANNEL_ID}
DISCORD_UPDATE_ROLE_ID: ${DISCORD_UPDATE_ROLE_ID}
DISCORD_SHOULD_CROSSPOST: ${DISCORD_SHOULD_CROSSPOST:-true}
STATUSPAGE_API_KEY: ${STATUSPAGE_API_KEY}
STATUSPAGE_PAGE_ID: ${STATUSPAGE_PAGE_ID}
STATUSPAGE_URL: ${STATUSPAGE_URL:-status.ticketsbot.cloud}
SERVER_ADDR: :${SERVER_ADDR:-8080}
DATABASE_PASSWORD: ${DATABASE_PASSWORD:-null}
DATABASE_URI: ${DATABASE_URI:-postgres://postgres:${DATABASE_PASSWORD:-null}@postgres-statusbot:5432/postgres?sslmode=disable}
JSON_LOGS: ${JSON_LOGS:-false}
LOG_LEVEL: ${LOG_LEVEL:-info}
ports:
- '${SERVER_ADDR:-8080}:${SERVER_ADDR:-8080}'
depends_on:
postgres:
condition: service_healthy
restart: true
networks:
- app-network

postgres:
image: postgres:15
container_name: postgres-statusbot
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ${DATABASE_PASSWORD:-null}
POSTGRES_DB: statusbot
ports: # Uncomment this line and the following line to access the main postgres on port 5433. Do not change the second port (5432) otherwise you cannot access the DB
- "5433:5432"
volumes:
- ./pgstatusbotdb:/var/lib/postgresql/data
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
networks:
- app-network
healthcheck:
test: ["CMD-SHELL", "psql -U postgres -d statusbot -c 'SELECT 1' > /dev/null 2>&1 || exit 1"]
interval: 10s
timeout: 5s
retries: 10

networks:
app-network:
driver: bridge
1 change: 1 addition & 0 deletions init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE TABLE IF NOT EXISTS incidents (id TEXT PRIMARY KEY, role_id BIGINT NOT NULL, message_id BIGINT NOT NULL, thread_id BIGINT NOT NULL, created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), status TEXT NOT NULL )