Skip to content

A discord bot written in Rust for helping out with the RITlug discord server

License

Notifications You must be signed in to change notification settings

RITlug/ritlug-discord-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ritlug-discord-bot

A discord bot written in Rust for helping out with the RITlug discord server

Configuration

Example environment variables

The Discord bot token is either read from the environment variable BOT_TOKEN, either from a .env file in the current directory or passed as an environment variable directly.

For the authentication system, the bot sends an email though a SMTP server. The SMTP_SERVER, SMTP_EMAIL, SMTP_USERNAME, and SMTP_PASSWORD environment variable are required to be set. Gmail provides free smtp access, and it's recommended if you dont have your own SMTP server.

Example config.json

irc.channels is a map from IRC channel names to Discord channel IDs. irc.use_tls defaults to true. If avatar is omitted or set to the empty string, the default Discord avatar will be used.

irc.flatten_bridges can be used when connecting to IRC channels that have other bridges connected. Keys correspond to IRC nicknames, values contain the keys syntax (a regex with two groups, the first matching the name and the second matching the message) and suffix (appended after the name).

verify.role is the 19-digit role id for the verify role. verify.allowed_emails is a list of all the allowed domain names for verification in the server. If verify isnt specified, verification will be disabled.

{
    "irc": {
        "server": "example.com",
        "nickname": "Example",
        "use_tls": true,
        "avatar": "",
        "channels": {
            "#channel-1": 123456789012345678,
            "#channel-2": 628318530717957646
        },
        "flatten_bridges": {
            "another_bridge": {
                "syntax": "^<([^>]*)> (.*)$",
                "suffix": "another bridge"
            }
        }
    },
    "verify": {
        "role": 1234567890123456789,
        "allowed_emails": [
            "rit.edu", "ritlug.com"
        ]
    }
}

Running with Docker

The Docker image can be build with

$ docker build -f deployments/docker/Dockerfile -t ritlug-discord-bot .

To run it, use

$ docker run \
--mount type=bind,source=/path/on/host/data/,target=/data \
-e BOT_TOKEN='token' \
-e SMTP_SERVER='smtp.gmail.com' \
-e SMTP_EMAIL='[email protected]' \
-e SMTP_USERNAME='user' \
-e SMTP_PASSWORD='pass' \
--rm -it ritlug-discord-bot

, replacing /path/on/host/data with the path to the host's data folder, the token with the Discord bot token, and the smtp_ vars with the smtp settings. The data folder contains the database.db and config.json files auto generated by the bot.

Docker compose can also be used to run the bot...

version: "3.9"

services:
  ritlug-discord-bot:
    container_name: ritlug-discord-bot
    image: ritlug-discord-bot
    environment:
    - BOT_TOKEN="token"
    - SMTP_SERVER="smtp.gmail.com"
    - SMTP_EMAIL="[email protected]"
    - SMTP_USERNAME="user"
    - SMTP_PASSWORD="pass"
    volumes:
    - ./data:/data

First time bot setup

To have the bot set up the various slash commands that the bot supports, you need to run the registration command. This can be done by sending a message like @bot-name register to your server. You will then be prompted for how you would like to register the commands (globally or just in this guild).

Once this is done, all the supported slash commands should work.

Usage

Use /help to see a list of slash commands with usage descriptions.

Some commands are also available via the IRC bridge, prefixed with r!. Use r!help for a list.

Contributing

See CONTRIBUTING.md for contribution guidelines

About

A discord bot written in Rust for helping out with the RITlug discord server

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •