Skip to content

domo is a Discord bot to help you manage your FOMO (fear of missing out).

License

Notifications You must be signed in to change notification settings

OliverCardoza/domo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

domo

domo is a Discord bot to help you manage your FOMO (fear of missing out).

It sends a notification when people join a voice channel in your server. I made this because I found myself frequently checking a server to see if anyone was there and LFG. Now I can rely on domo to push this info to me instead.

How it works

The bot is added to a server and listens to voice state update events. When it encounters an event of someone joining a voice channel it posts a message to a configured text channel. Once installed in a server, users can mute the bot or the update channel if they don't want to receive domo updates.

Initially the update messages were a bit spammy so a configurable rate limit was added. This can be used to prevent someone rapidly joining and leaving a channel from spamming messages.

Add to a Server

NOTE: At the moment this is only a private bot. You can self-host using the code and deployment instructions in this repo.

Authorize the Bot

Complete the authorization flow by visiting the following link:

This link identifies the domo app id and includes the required permission set:

  • Read Messages/View Channels
  • Send Messages
  • Send Messages in Threads

Register domo update channel

The domo config (JSON file) must be updated for each server domo is added to. This is inconvenient but is fine for now since the goal isn't to make this a public bot. It also saves the hassle of integrating a secondary storage system.

Update config/bot_main.json with the server's GuildID and a channel ID where domo has permission to post messages. This channel is where domo will publish its update messages. A rate_limit_sec value can also be configured to limit how often domo posts.

Channel Category

To avoid accidentally revealing when people join private voice channels the bot filters voice events when the voice channel category does not match the domo update channel category. This means if domo is configured to update a text channel in the Main category it will only report voice channel joins in the Main category. The lack of a category (root) will match other voice channels in root.

This is a bit of a hack to avoid dealing with comparing the visibility of the text channel with each voice channel. The proper way to do this would be to compare identify all roles/users which can see the update channel: T. Then identify all roles/users which can see the voice channel from the event: V. Then verify that V is a superset of T before posting.

The channel category acts as a reasonable proxy for visibiltiy because you can configure all channels in a category to have the same visibility.

Development

Download and install Go: Instructions

To run the bot first grab the token from the bot page. Then run the bot using the run command below:

go run cmd/bot/main.go -t ${TOKEN_GOES_HERE}

This registers the bot to listen for events in the Dev Server.

To run the bot using the main config:

go run cmd/bot/main.go -t ${TOKEN_GOES_HERE} -c config/bot_main.json

NOTE: This may result in duplicate update messages from the bot deployed to Google Cloud.

Testing

Github Actions workflows are used to test pull requests. Alternatively you can locally run ./scripts/presubmit_go.sh or go test ./....

Deployment

Deployment requires two tools be installed:

  • gcloud is used to authenticate and configure the GCP project
  • ko is used to build a docker container for the bot binary
    • go install github.com/google/ko@latest

Once these tools are installed the following script can be run to build and deploy a new container version:

./scripts/deploy.sh

NOTE: This relies on some manually configured defaults which were set up in Cloud Console. The most notable are "secrets" which are used to provide the container the bot config (JSON file) and discord token (env var).

Initial Discord App setup

Below is a historical account of how this was configured:

  1. Visit https://discord.com/developers/applications
  2. Create a new application
  3. Within the app go to "Bot section and create a bot
  4. Disable "Public Bot": this prevents random people adding it to their servers

Cloud Setup

Terraform is used to configure the cloud infra to run the bot. It is currently configured on GCP. Steps:

  1. Create a GCP project
  2. Create a GCS bucket for terraform state
  3. Install terraform-cli: https://learn.hashicorp.com/tutorials/terraform/install-cli
  4. Set the project id in terraform/main.tfvars
  5. Set the Terraform bucket id in terraform/main.tf (can't be set as a variable)
  6. Export the project id as an env var: GOOGLE_PROJECT=$PROJECT_ID
  7. Run terraform
    terraform -chdir=terraform init
    terraform -chdir=terraform validate
    terraform -chdir=terraform plan -var-file=main.tfvars
    terraform -chdir=terraform apply -var-file=main.tfvars
    

Links

About

domo is a Discord bot to help you manage your FOMO (fear of missing out).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published