a discord bot that gets images from reddit. simple.
first, create a .env
file that has the following keys:
POSTMAN_DATABASE_URL
: location of a postgres database (not required for docker)POSTMAN_DISCORD_TOKEN
: the discord token the bot will usePOSTMAN_DEFAULT_SUB
: the default subreddit that commands usePOSTMAN_ADMIN
: the discord id of the admin user (most likely yours)POSTMAN_COOLDOWN_TIME
: the cooldown between comands in seconds (default 3 seconds)POSTMAN_PREFIX
: the prefix the bot will use
# not required for docker
POSTMAN_DATABASE_URL=postgres://user:pass@hostname:port/database
POSTMAN_DISCORD_TOKEN=your.token.here
POSTMAN_DEFAULT_SUB=memes
POSTMAN_ADMIN=99999999999
# not required (default 3 seconds)
POSTMAN_COOLDOWN_TIME=5
POSTMAN_PREFIX=-
note: you need
install the diesel
cli
$ cargo install --no-default-features --features postgres diesel_cli
run migrations
$ diesel migration run --database-url your-database-url
build
$ cargo build --release
to run use
$ cargo run --release
or
$ ./target/release/postman
build the image
$ docker-compose build
run
$ docker-compose up -d
backup
$ sudo docker exec postman_database_1 pg_dumpall -c -U postman > dump.sql
to restore copy the sql as backup.sql
into the root directory
$ cp ../your-backup.sql backup.sql
and then rebuild the image and run
$ sudo docker-compose build
$ sudo docker-compose up -d
backup
$ pg_dumpall -c -U database_user > dump.sql
restore
$ cat dump.sql | psql -U database_user
following rust conventions, this bot is dual licensed under the MIT and APACHE-2.0 licenses.