Compare commits

..

No commits in common. "98191d29ee866a53346ac1048f6ff31f9bf27aa3" and "094d210f64f1ddd8d4a57538c4ddc279a876a6aa" have entirely different histories.

12 changed files with 23 additions and 56 deletions

2
Cargo.lock generated
View File

@ -2188,7 +2188,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
[[package]]
name = "reminder-rs"
name = "reminder_rs"
version = "1.6.10"
dependencies = [
"base64",

View File

@ -1,10 +1,8 @@
[package]
name = "reminder-rs"
name = "reminder_rs"
version = "1.6.10"
authors = ["Jude Southworth <judesouthworth@pm.me>"]
edition = "2021"
license = "AGPL-3.0 only"
description = "Reminder Bot for Discord, now in Rust"
[dependencies]
poise = "0.4"
@ -35,14 +33,12 @@ path = "postman"
path = "web"
[package.metadata.deb]
depends = "$auto, python3-dateparser"
suggests = "mysql-server-8.0, nginx"
depends = "$auto, nginx, python3, python3-venv"
suggests = "mysql-server-8.0"
maintainer-scripts = "debian"
assets = [
["target/release/reminder-rs", "usr/bin/reminder-rs", "755"],
["conf/default.env", "etc/reminder-rs/default.env", "600"],
# ["web/static/", "var/www/reminder-rs/static", "755"],
# ["nginx/reminder-rs", "etc/nginx/sites-available/reminder-rs", "755"]
["conf/default.env", "etc/reminder-rs/default.env", "600"]
]
[package.metadata.deb.systemd-units]

View File

@ -1,9 +0,0 @@
FROM ubuntu:20.04
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH
RUN apt update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install -y gcc gcc-multilib cmake pkg-config libssl-dev curl mysql-client-8.0
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal
RUN cargo install cargo-deb

View File

@ -9,7 +9,7 @@ You'll need rustc and cargo for compilation. To run, you'll need Python 3 still
### Compiling
Install build requirements:
`sudo apt install gcc gcc-multilib cmake libssl-dev build-essential python3-dateparser`
`sudo apt install gcc gcc-multilib cmake libssl-dev build-essential`
Install Rust from https://rustup.rs
@ -28,7 +28,9 @@ Use MySQL 8. MariaDB is confirmed not working at the moment.
Load the SQL files in order from "migrations" to generate the database schema.
### Setting up Python
Reminder Bot uses `python3-dateparser` to handle dates. This depends on Python 3.
Reminder Bot by default looks for a venv within it's working directory to run Python out of. To set up a venv, install `python3-venv` and run `python3 -m venv venv`. Then, run `source venv/bin/activate` to activate the venv, and do `pip install dateparser` to install the required library.
Remember where you create the venv! You may need to change the `PYTHON_LOCATION` variable in the next step to point to your Python binary if the venv is not in your working directory.
### Environment Variables
Reminder Bot reads a number of environment variables. Some are essential, and others have hardcoded fallbacks. Environment variables can be loaded from a .env file in the working directory.
@ -44,3 +46,8 @@ __Other Variables__
* `CNC_GUILD` - default `None`, accepts a single Discord guild ID for the server that the subscription roles belong to
* `PYTHON_LOCATION` - default `venv/bin/python3`. Can be changed if your Python executable is located somewhere else
* `THEME_COLOR` - default `8fb677`. Specifies the hex value of the color to use on info message embeds
* `DM_ENABLED` - default `1`, if `1`, Reminder Bot will respond to direct messages
### Todo List
* Convert aliases to macros

View File

@ -1,3 +0,0 @@
fn main() {
println!("cargo:rerun-if-changed=migrations");
}

View File

@ -6,8 +6,7 @@ PATREON_ROLE_ID=
LOCAL_TIMEZONE=
MIN_INTERVAL=
PYTHON_LOCATION=/usr/bin/python3
DONTRUN=web
PYTHON_LOCATION=
SECRET_KEY=
REMIND_INTERVAL=

2
debian/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

13
debian/postinst vendored
View File

@ -1,13 +0,0 @@
#!/bin/bash
set -e
id -u reminder &>/dev/null || useradd -r -M reminder
if [ ! -f /etc/reminder-rs/config.env ]; then
cp /etc/reminder-rs/default.env /etc/reminder-rs/config.env
fi
chown reminder /etc/reminder-rs/config.env
#DEBHELPER#

11
debian/postrm vendored
View File

@ -1,11 +0,0 @@
#!/bin/bash
set -e
id -u reminder &>/dev/null || userdel reminder
if [ -f /etc/reminder-rs/config.env ]; then
rm /etc/reminder-rs/config.env
fi
#DEBHELPER#

View File

@ -14,7 +14,7 @@ CREATE TABLE guilds (
default_avatar VARCHAR(512) DEFAULT 'https://raw.githubusercontent.com/reminder-bot/logos/master/Remind_Me_Bot_Logo_PPic.jpg' NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (default_channel_id) REFERENCES channels(id) ON DELETE SET NULL
FOREIGN KEY (default_channel_id) REFERENCES reminders.channels(id) ON DELETE SET NULL
);
CREATE TABLE channels (
@ -35,7 +35,7 @@ CREATE TABLE channels (
guild_id INT UNSIGNED,
PRIMARY KEY (id),
FOREIGN KEY (guild_id) REFERENCES guilds(id) ON DELETE CASCADE
FOREIGN KEY (guild_id) REFERENCES reminders.guilds(id) ON DELETE CASCADE
);
CREATE TABLE users (
@ -55,7 +55,7 @@ CREATE TABLE users (
patreon BOOLEAN NOT NULL DEFAULT 0,
PRIMARY KEY (id),
FOREIGN KEY (dm_channel) REFERENCES channels(id) ON DELETE RESTRICT
FOREIGN KEY (dm_channel) REFERENCES reminders.channels(id) ON DELETE RESTRICT
);
CREATE TABLE roles (
@ -67,7 +67,7 @@ CREATE TABLE roles (
guild_id INT UNSIGNED NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (guild_id) REFERENCES guilds(id) ON DELETE CASCADE
FOREIGN KEY (guild_id) REFERENCES reminders.guilds(id) ON DELETE CASCADE
);
CREATE TABLE embeds (

View File

@ -88,8 +88,8 @@ async fn main() -> Result<(), Box<dyn StdError + Send + Sync>> {
async fn _main(tx: Sender<()>) -> Result<(), Box<dyn StdError + Send + Sync>> {
env_logger::init();
if Path::new("/etc/reminder-rs/config.env").exists() {
dotenv::from_path("/etc/reminder-rs/config.env")?;
if Path::new("/etc/soundfx-rs/default.env").exists() {
dotenv::from_path("/etc/soundfx-rs/default.env")?;
}
let discord_token = env::var("DISCORD_TOKEN").expect("Missing DISCORD_TOKEN from environment");

View File

@ -2,7 +2,6 @@
Description=Reminder Bot
[Service]
User=reminder
Type=simple
ExecStart=/usr/bin/reminder-rs
Restart=always