Skip to content

Pyrite is a discord moderation bot for moderating user nicknames and usernames in your server!

License

Notifications You must be signed in to change notification settings

Pyrite-X/Pyrite

Repository files navigation

Pyrite

Pyrite is your next anti-phishing Discord bot through moderating user nicknames and usernames in your server!

By default, this is done by matching a person's username or nickname to the name of a well-known Discord bot, as defined here.

There is also an included rule system, allowing you to remove any users from your server who may match that custom rule!

Tip

Want to learn more? Check out the provided guides!


Features

  • Automatically check users when they join and when their name or nickname changes
  • Configurable name matching to a bot list.
    • Entire-name matching
    • Partial/fuzzy matching
  • Rule system for custom names/strings to compare against.
    • Regex rules and standard string rules.
  • Full server scanning
  • Self-hostable!

Invite

Are you interested yet? If so, check out the bot for yourself! Invite Pyrite!


Self Hosting

Although I would much appreciate it if you use the hosted version instead, it is possible to self-host Pyrite!

Warning

This is not an exhaustive guide. It is presumed that if you are self-hosting, you know how to configure SSL certificates (or use a reverse proxy), open ports if necessary, and edit Docker files where necessary.


The following guide uses Docker to run Pyrite. However, it can be run in Dart without Docker as well. See the main Dockerfile for the commands to build and run Pyrite.

A docker-compose.yml is provided, which sets up the bot's necessary services, excluding MongoDB.

Initial Setup

The compose file is set up to work with Portainer (although it is not recommended to use Portainer to start the bot). As such, the environment file is expected to be named stack.env. Make sure to change this in the compose file if you don't want your .env file to be called stack.env.

  • Clone this repository to your system

  • Create a file named stack.env in the root of the cloned directory.

  • Spin up a MongoDB instance

  • Fill out the .env variables
    • With the compose setup, REDIS_HOST will be redis, REDIS_PORT will be the default 6379, and REDIS_PASS will be left unset.
      - APP_ID => Your bot's application ID from Discord
      - PUB_KEY => Your bot's public key from Discord
      - TOKEN => The token for your bot. Don't share this!
      
      - DISCORD_URL => (OPTIONAL) Upstream URL for Discord (if you are using a proxy such as [Nirn](https://github.com/germanoeich/nirn-proxy)
      - DISCORD_SCHEME => (OPTIONAL) Is the proxy HTTP or HTTPS
      - PORT => (OPTIONAL) The port that the Discord proxy is serving on.
    
      - MONGO_URI => The connection string to connect to the MongoDB database.
      - REDIS_HOST => The hostname/IP of the system providing Redis.
      - REDIS_PORT => Port that Redis is exposed on.
      - REDIS_PASS => (OPTIONAL) Password string that is securing Redis.
      
      - CERT_BASE_PATH => (OPTIONAL) Path for the folder where `fullchain.pem` and `privkey.pem` exist under (TLS/SSL certificates). Not required if Pyrite is running behind a reverse proxy.
        - If you are using this, and using Docker, make sure the folder is mounted under the `webserver` service in the compose file.
          The path provided here will be based on the file system in the container, not on the host.
    

Running the Bot

Running using the included .sh files.
  • Make sure you can execute the docker_runner.sh and docker_update.sh files.
    • docker_runner builds and runs Pyrite via Docker Compose
    • docker_update rebuilds and redeploys the gateway and webserver containers made by Pyrite.
  • To get started, simply execute ./docker_runner.sh and wait for it to complete!
Running using Docker commands.
  • Build the Pyrite image for the compose file to work correctly.
    • Run docker build -t local/pyrite:latest -f Dockerfile . from the root of the repository.
  • Run docker compose up -d to then start all the necessary containers.
  • Update rollouts can be done by rebuilding the image, then redeploying the gateway and webserver containers by running docker compose up --no-deps -d gateway && docker compose up --no-deps -d webserver

Additional Information

Pyrite receives interactions via HTTP POST requests rather than over the gateway. Because of this, you will need to have your port for the pyrite_http container published. The included compose setup does this for you, exposing the port 8008. It can be changed by modifying bin/pyrite_http.dart and the docker-compose.yml accordingly.

Also, Discord requires the use of HTTPS for REST-based interactions, so you will need to set that up in your preferred way. My preferred method for simple access is to use Tailscale Funnel to expose the port instead of port forwarding.

Important

Interactions are received on /ws rather than the webserver's root URL (e.g. 127.0.0.1:8008/ws). If you have a domain, it would be example.com:8008/ws. Make sure this is included in the URL you paste into the developer portal for your application.

About

Pyrite is a discord moderation bot for moderating user nicknames and usernames in your server!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages