Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

add docker compose infra for local mongo, refactor command disabled checking #41

Merged
merged 3 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
33 changes: 33 additions & 0 deletions infrastructure/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# https://docs.docker.com/compose/networking/
version: "3.8"
services:
# the dockerfile to build turingbot is located at ../
turingbot:
container_name: turingbot
build: ../
# mount the config and secrets
volumes:
- type: bind
source: ../config.jsonc
target: /usr/src/turingbot/config.jsonc
- type: bind
source: ../secrets.jsonc
target: /usr/src/turingbot/secrets.jsonc

restart: unless-stopped
depends_on:
- mongo
# at some point, i would like to have it be possible for mongodb to be routed in a way that it's accessible when the bot is not running in the docker container, maybe a port fwd
mongo:
container_name: mongo
image: mongo
ports:
- "27017:27017"
volumes:
- mongo:/data/db
environment:
# change these in production
- MONGO_INITDB_ROOT_PASSWORD=root
- MONGO_INITDB_ROOT_USERNAME=root
volumes:
mongo:
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion secrets.default.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
// Otherwise set it to mongodb://
"protocol": "mongodb://",
// the IP address or URL of your mongodb instance
"address": "mongodb.example.com",
// if using docker compose, set this to `mongo`
"address": "mongo",
// authentication credentials
// docker compose default creds are `root`, and `root`, *do not use this in prod*
"username": "YOUR_MONGO_USERNAME",
"password": "YOUR_MONGO_PASSWORD"
},
Expand Down
18 changes: 7 additions & 11 deletions src/core/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,14 @@ function listenForSlashCommands() {
commandPath.push(subcommand);
}
const resolutionResult = resolveModule(commandPath);
// if a module was found
if (resolutionResult.foundModule !== null) {
// first see if the root module is enabled
if (!resolutionResult.foundModule.config ?? {enabled: false}.enabled) {
if (
resolutionResult.foundModule.config ??
{enabled: false}.enabled !== true
) {
replyToInteraction(interaction, {
embeds: [embed.errorEmbed('This command is disabled.')],
ephemeral: true,
});
}
if (resolutionResult.foundModule.config.enabled !== true) {
replyToInteraction(interaction, {
embeds: [embed.errorEmbed('This command is disabled.')],
ephemeral: true,
});
return;
}

// validate permissions
Expand Down