From e6414abaf195c70967d13b3705d222af26b036c3 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Sat, 26 Feb 2022 00:10:04 +0100 Subject: [PATCH] docker shit --- .dockerignore | 1 + Dockerfile | 17 +++++++++++++++++ README.md | 9 +++++++++ entrypoint.sh | 7 +++++++ src/general.rs | 5 +---- 5 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9f97022 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +target/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c76f0ed --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +#FROM rust:latest as build +#RUN sudo apt-get install musl-tools +#WORKDIR /app +#COPY . ./ +#RUN rustup target add x86_64-unknown-linux-musl +#RUN cargo build --release --target x86_64-unknown-linux-musl + +FROM alpine:latest +#COPY --from=build /app/target/x86_64-unknown-linux-musl/release/killjoy_turret /app/killjoy_turret +COPY ./target/x86_64-unknown-linux-musl/debug/killjoy_turret /usr/local/bin/killjoy_turret + +COPY ./config.json /app/config.json +COPY ./entrypoint.sh /app/entrypoint.sh + +ENV CONFIG_PATH=/app/config.json + +ENTRYPOINT ["/usr/local/bin/killjoy_turret"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..877f0d4 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +needs a config file either with the path of the env var `CONFIG_PATH` or `./config.json` + + +```json +{ + "token": "", + "auto_react": [["keyword", "reaction unicode"]] +} +``` \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..2dfb9c3 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +while true ; +do + /usr/local/bin/killjoy_turret + sleep 10 +done \ No newline at end of file diff --git a/src/general.rs b/src/general.rs index 5ae3cf9..8946492 100644 --- a/src/general.rs +++ b/src/general.rs @@ -21,10 +21,7 @@ pub async fn normal_message(ctx: &Context, msg: &Message) { let lowercase_content = msg.content.to_lowercase(); for (trigger, reaction) in &reactions.auto_react { if lowercase_content.contains(trigger) { - if let Err(why) = msg - .react(&ctx.http, ReactionType::Unicode(reaction.clone())) - .await - { + if let Err(why) = msg.react(&ctx.http, ReactionType::Unicode(reaction.clone())).await { eprintln!("Error reacting {}", why); } }