Skip to content

A multi-channel confession bot for Discord that supports anonymous replies and channel moderation.

License

AGPL-3.0, Unknown licenses found

Licenses found

AGPL-3.0
LICENSE
Unknown
COPYING.md
Notifications You must be signed in to change notification settings

BastiDood/spectro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spectro Logotype

Spectro is a Discord bot that enables your community members to post anonymous confessions and replies to moderator-configured channels. However, for the sake of moderation, confessions are still logged for later viewing.

Development

Spectro is a standard full-stack SvelteKit web application that leverages PostgreSQL as the database layer.

Managing Environment Variables

For convenience, the repository includes env:* scripts for loading environment variables from .env.* files. These are meant to be used as prefixes for other package scripts.

# Run the database migrations with `.env.development` variables.
pnpm env:dev pnpm db:migrate

# Register the Discord application commands.
pnpm env:prod pnpm discord:register

Managing the Database

Spectro requires a PostgreSQL database for data persistence. For convenience, we use Docker Compose to set up a local installation. The following environment variables are required for this to work.

Name Description
POSTGRES_DATABASE_URL The URL connection string for the PostgreSQL development database.
POSTGRES_PASSWORD The password with which to initialize the default postgres user.
# Download PostgreSQL with Docker (Compose).
# Run and initialize an empty database.
# Requires `POSTGRES_PASSWORD`.
docker compose --profile=dev up --detach

# Run the database migrations.
# Requires `POSTGRES_DATABASE_URL` already in scope.
pnpm db:migrate

# Shut down the PostgreSQL server.
docker compose --profile=dev down

Registering Callback Endpoints

The bot relies on two callback endpoints that receives webhook events from Discord:

  1. The interactions endpoint (i.e., /webhook/discord/interaction/) for receiving application commands via HTTP POST requests from Discord.
  2. The webhook events endpoint (i.e., /webhook/discord/event/) for receiving application authorization events from Discord.

Registering the Application Commands

To register the application commands in Discord, a one-time initialization script must be run whenever commands are added, modified, or removed. The script is essentially a simple HTTP POST request wrapper over the Discord REST API.

# Register the application commands.
# Requires `DISCORD_APPLICATION_ID` and `DISCORD_BOT_TOKEN` already in scope.
pnpm discord:register

Running the Web Server

Spectro requires some environment variables to run correctly. If the following table is outdated, a canonical list of variables can be found in the src/lib/server/env/*.ts files.

Name Description
POSTGRES_DATABASE_URL The URL connection string for the PostgreSQL production database.
DISCORD_APPLICATION_ID The publicly known Discord application ID that will be used for the verification of incoming webhooks.
DISCORD_PUBLIC_KEY The public key of the Discord application that will be used for the verification of incoming webhooks.
DISCORD_BOT_TOKEN The secret key of the Discord application that will be used for the verification of OAuth2 client credential flows.

The following variables are optional in development, but highly recommended in the production environment.

Name Description
AXIOM_DATASET An Axiom dataset to which structured logs will be delivered.
AXIOM_TOKEN The Axiom token used to authenticate with the ingest.
# Install the dependencies.
pnpm install

# Synchronize auto-generated files from SvelteKit.
pnpm sync

# Start the development server with live reloading + hot module replacement.
pnpm dev

# Compile the production build (i.e., with optimizations).
pnpm build

# Start the production preview server.
pnpm preview

Linting the Codebase

# Check Formatting
pnpm fmt # prettier

# Apply Formatting Auto-fix
pnpm fmt:fix # prettier --write

# Check Linting Rules
pnpm lint:html   # linthtml
pnpm lint:css    # stylelint
pnpm lint:js     # eslint
pnpm lint:svelte # svelte-check

# Check All Lints in Parallel
pnpm lint

Legal

The Spectro project is licensed under the GNU Affero General Public License v3.0. However, some files (e.g., brand assets) are exceptions that have been licensed under different terms and limitations. See the COPYING.md file for more details.

Acknowledgements

Spectro is dedicated to the hundreds of students at the Department of Computer Science, University of the Philippines - Diliman who rely on anonymous confessions for their daily dose of technical discourse, academic inquiries, heated rants, quick-witted quips, and other social opportunities.

Let Spectro bind the wider computer science community closer together in pursuit of collaboration in the service of our nation.

  • For the selfless student leaders keeping the spirit of the department alive.
  • For the tireless mentors who frequently share their knowledge and gifts to every academic inquiry.
  • For the seasoned veterans and alumni who impart their wisdom about the "real world" out there.
  • For the harshest critics of the department who only strive for the quality of education that we deserve.
  • For the wittiest comedians who brighten up the otherwise dry discourse.
  • For the persevering pupils who exemplify utmost scholarship even in the face of setbacks.
  • For the struggling students who nevertheless keep pushing out of passion for their craft.
  • For the anonymous lurkers who now feel safer and empowered to participate.

Spectro is here is for you. 👻


Coded with ❤ by Basti Ortiz. Themes, designs, and branding by Jelly Raborar.

About

A multi-channel confession bot for Discord that supports anonymous replies and channel moderation.

Topics

Resources

License

AGPL-3.0, Unknown licenses found

Licenses found

AGPL-3.0
LICENSE
Unknown
COPYING.md

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •