Skip to content
IzieStrattPublic

About

DMs you when your Prox2 post has a update on if it's been posted.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Repository files navigation

Mrox

Mrox is a Slack bot that watches [Prox2 / Owl] confession activity and DMs the submitter when their confession's status changes (approved, approved for meta, denied, or unapproved).

Currently implemented in test.ts (the actively-developed version).

What it does

  • /mrox {id} — start tracking a confession by its numeric ID (or /mrox untrack {id}). Only the configured user can call it while the test guard is on.
  • App Home box — paste/type a confession ID and press Enter, no command needed. Tracked confessions are listed with Untrack buttons.
  • Watches the confession logs channel for status updates like Confession #40289 was approved.
  • DMs the submitter with the result:
    • Approved → link to the post in #confessions
    • Approved for meta → link in #meta
    • Denied → includes the reason pulled from the log thread
    • Unapproved → thread-nuked notice
  • Marks confessions resolved and purges them 2 days later.
  • Easter egg for impossible states (a status update on an already-resolved confession).

Setup

  1. Create the Slack app from app_manifest.yaml (api.slack.com → Create New App → From manifest).

  2. Add tokens to .env (see .env.example):

    • SLACK_BOT_TOKEN (xoxb-*) — Bot User OAuth Token
    • SLACK_APP_TOKEN (xapp-*) — App-Level Token with connections:write
  3. Invite the bot to #confessions, #meta, and the confession logs channel.

  4. Install the app, then run:

    npm start

Configuration

All channel IDs and toggles have sensible defaults in test.ts and can be overridden with env vars (see .env.example):

Variable Default Purpose
CHANNEL_CONFESSIONS CNMU9L92Q #confessions
CHANNEL_CONFESSION_LOGS C08R8LE6DDG logs / status channel
CHANNEL_META C0188CY57PZ #meta
OWL_BOT_ID B0C6JPG4W0G Prox2/Owl bot id
WORKSPACE_DOMAIN hackclub.enterprise.slack.com permalink building
RESTRICT_TO_USER true only ALLOWED_USER_ID may use /mrox
ALLOWED_USER_ID U09KKMHLS15 the allowed user
VERIFY_ID_IN_STATUS false require status to reference the id
DEBUG false verbose logging

To test without touching the real flow, override the CHANNEL_* variables to point at throwaway channels.

Data

  • confessions.json — tracked confessions (id, userId, resolved, date, postTs, status). Writes are atomic.

Notes

  • Mrox cannot read other users' DMs with Prox2; Slack does not allow bots to read DMs they aren't part of. Track via /mrox {id} or the App Home box.
  • The bot only acts on status messages from the Owl bot (OWL_BOT_ID) in the logs channel.
  • The bot needs channels:history and to be a member of the channels it scans.

Switching to Rust

rust/ is a port of test.ts (behaviour and file formats are listed in rust/PARITY.md). It reads and writes the same confessions.json, config.yaml and .env, so either bot can take over from the other.

Run one bot at a time. Two Socket Mode connections split the events between them, so one bot would miss half of them. The Rust unit is deploy/mrox-rust.service; it runs rust/target/release/mrox with the same user, working directory and env file as mrox.service.

  1. Build on the server (as gaypeople; cargo must be on the PATH, or in ~/.cargo/bin):

    cd ~/code/mrox/rust && cargo build --release

    deploy/update.sh does this itself whenever rust/ changes in a pull.

  2. Set ALLOWED_USER_ID in .env. The Rust port has no built-in default: unset, /mrox refuses everyone (the TypeScript default is not copied into the code). RESTRICT_TO_USER=false opens it to everyone, as before.

  3. Install the unit and allow the update script to restart it:

    sudo cp deploy/mrox-rust.service /etc/systemd/system/ && sudo systemctl daemon-reload
    echo 'gaypeople ALL=(root) NOPASSWD: /usr/bin/systemctl restart mrox-rust' | sudo tee -a /etc/sudoers.d/mrox
  4. Switch over (stop the TypeScript bot first, then start the Rust one):

    sudo systemctl stop mrox && sudo systemctl disable mrox
    sudo systemctl enable --now mrox-rust
    journalctl -u mrox-rust -f   # expect "(test.ts) Bot is running..."

deploy/update.sh restarts mrox-rust while it is active, and mrox otherwise, so the daily update keeps working on either side of the switch.

Rollback (state is in the shared files, so nothing is lost; pending rejections are stored in confessions.json and resume on start):

sudo systemctl stop mrox-rust
sudo systemctl enable --now mrox

About

DMs you when your Prox2 post has a update on if it's been posted.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages