Skip to content

Commit

Permalink
Merge pull request #98 from ValgulNecron/dev
Browse files Browse the repository at this point in the history
V2.1
  • Loading branch information
ValgulNecron committed Jan 26, 2024
2 parents 8c4dfb0 + 0006a3e commit fd432c9
Show file tree
Hide file tree
Showing 165 changed files with 6,367 additions and 1,486 deletions.
20 changes: 14 additions & 6 deletions .env-default
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
DISCORD_TOKEN="Your token here"
AI_API_TOKEN="Your token here for the ai part"
AI_API_TOKEN="Your token here for the ai part""
AI_API_BASE_URL="The url for the request open ai or any openai proxy one do not forget to end with a / the url"
AI_IMAGE_API_TOKEN="Your token here for the ai part""
AI_IMAGE_API_BASE_URL="The url for the request open ai or any openai proxy one do not forget to end with a / the url"
IMAGE_GENERATION_MODELS_ON=True
IMAGE_GENERATION_MODELS=""
RUST_LOG="info" # trace, debug, info, warn or error
NSFW=True# if the bot should honor the nsfw for image if set to true it will if false it will not. (turn it off if you are 100% the model you use for image can't generate nsfw)
REMOVE_OLD_COMMAND_ON_STARTUP=True# if the bot should remove the old command when it start. recommended to set it for the 1st launch or when updating to a breaking change version
DB_TYPE="sqlite"
IMAGE_GENERATION_MODELS="The models you want to use for the image generation if IMAGE_GENERATION_MODELS_ON is True"
IMAGE_QUALITY="hd dall-e-3"
IMAGE_STYLE="vivid dall-e-3"
IMAGE_SIZE="1024x1024 depend on models"
RUST_LOG="warn/error/info/debug/trace"
NSFW=True
REMOVE_OLD_COMMAND_ON_STARTUP=True
DB_TYPE="sqlite/postgres"
SAVE_IMAGE="local/remote/false"
SAVE_SERVER="imgur/catbox"
TOKEN="catbox userhash / imgur client id"
8 changes: 4 additions & 4 deletions .github/workflows/docker-image-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch:

concurrency:
group: "dev"
group: "dev_docker"
cancel-in-progress: false

jobs:
Expand All @@ -28,9 +28,9 @@ jobs:
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64,linux/arm64/v8
platforms: linux/amd64, linux/arm64/v8
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/kasuki:dev
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/kasuki:devbuildcache
cache-to: type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/kasuki:devbuildcache,mode=max
build-args: |
BUILDKIT_INLINE_CACHE=1
8 changes: 4 additions & 4 deletions .github/workflows/docker-image-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch:

concurrency:
group: "release"
group: "release_docker"
cancel-in-progress: false

jobs:
Expand All @@ -28,9 +28,9 @@ jobs:
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64,linux/arm64/v8
platforms: linux/amd64, linux/arm64/v8
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/kasuki:latest
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/kasuki:latestbuildcache
cache-to: type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/kasuki:latestbuildcache,mode=max
build-args: |
BUILDKIT_INLINE_CACHE=1
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
# will have compiled files and executables
debug/
target/
.idea
.idea/**

image/


# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Expand Down Expand Up @@ -348,3 +353,6 @@ FodyWeavers.xsd
*.log.*
*.sig
pkg/

cache.db
data.db
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
### Code style


Please use clippy and do not add new warning (or as little as possible, so it can be easily fixed.)
Please use clippy and do not add new warning (or as little as possible)
Always add docstring to public function except for autocomplete, run and register.
also add comment to "hard" thing so people know why you did this.

Expand Down
26 changes: 15 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,33 @@ description = "A discord bot written in rust that get info from anilist API"
readme = "readme.md"
repository = "https://github.com/ValgulNecron/kasuki"
license-file = "LICENSE"
include = ["src", "LICENSE"]
exclude = [".*", "json", "logs"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
regex = "1.10.2"
reqwest = { version = "0.11.22", features = ["json"] }
serde = "1.0.193"
serde_json = "1.0.108"
regex = "1.10.3"
reqwest = { version = "0.11.23", features = ["json"] }
serde = "1.0.195"
serde_json = "1.0.111"
serenity = { version = "0.12.0", default-features = false, features = ["client", "gateway", "rustls_backend", "model", "utils", "full"] }
tokio = { version = "1.35.1", features = ["full"] }
sqlx = { version = "0.7.3", features = ["sqlite", "runtime-tokio-native-tls"] }
sqlx = { version = "0.7.3", features = ["sqlite", "runtime-tokio-native-tls", "postgres"] }
rand = "0.8.5"
chrono = "0.4.31"
uuid = { version = "1.6.1", features = ["v4"] }
chrono = "0.4.33"
uuid = { version = "1.7.0", features = ["v4"] }
dotenv = "0.15.0"
image = "0.24.7"
base64 = "0.21.5"
image = "0.24.8"
base64 = "0.21.7"
tracing = { version = "0.1.40" }
once_cell = "1.19.0"
tracing-subscriber = { version = "0.3.18", features = ["default", "env-filter"] }
tracing-core = "0.1.32"
log = "0.4.20"
serde_with = { version = "3.5.1", features = ["macros"] }
rust-fuzzy-search = "0.1.1"
palette = "0.7.3"
catbox = "0.8.2"
imgur = "0.7.0"

[profile.dev]
codegen-units = 512
Expand Down
19 changes: 13 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
FROM rust:1.74-buster AS builder
FROM rust:slim-bookworm AS builder

RUN USER=root cargo new --bin kasuki

RUN apt-get update && apt-get install -y --no-install-recommends \
libssl-dev libsqlite3-dev \
libpng-dev libjpeg-dev \
ca-certificates pkg-config \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /kasuki

COPY ./Cargo.toml ./Cargo.toml
Expand All @@ -14,7 +20,7 @@ COPY ./src ./src
RUN rm ./target/release/deps/kasuki*
RUN cargo build --release

FROM debian:buster-slim AS bot
FROM debian:trixie-slim AS bot

LABEL maintainer="valgul"
LABEL author="valgul"
Expand All @@ -25,13 +31,14 @@ HEALTHCHECK CMD ps aux | grep kasuki || exit 1

WORKDIR /kasuki/

COPY json /kasuki/json

RUN apt-get update && apt-get install -y --no-install-recommends \
libssl-dev libsqlite3-dev \
libpng-dev libjpeg-dev \
ca-certificates && rm -rf /var/lib/apt/lists/*
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /kasuki/target/release/kasuki /kasuki/.
COPY --from=builder /kasuki/target/release/kasuki/ /kasuki/

COPY json /kasuki/json

CMD ["./kasuki"]
2 changes: 0 additions & 2 deletions _not_used/readme.md

This file was deleted.

4 changes: 3 additions & 1 deletion anilist_post.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ It also convert anilist flavored markdown into discord markdown (and also includ
you can find the bot on [github](https://github.com/ValgulNecron/kasuki)
or [add it with](https://discord.com/api/oauth2/authorize?client_id=923286536445894697&permissions=533113194560&scope=bot)

It also support localisation. If you want to add one you simply need to edit the json file on the github repos. (I will accept new translation on the repos (if it seems good on deepl), but will not add more myself since I know no one who speaks other language to help me translate it.)
It also support localisation. If you want to add one you simply need to edit the json file on the github repos. (I will
accept new translation on the repos (if it seems good on deepl), but will not add more myself since I know no one who
speaks other language to help me translate it.)
You can also request feature and report issue.


Expand Down
Binary file removed cache.db
Binary file not shown.
16 changes: 12 additions & 4 deletions compose-default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@ services:
tty: true
environment:
- DISCORD_TOKEN=your_discord_token_here
- AI_API_TOKEN=your_token_here_for_the_ai_part
- AI_API_BASE_URL=the_url_for_the_request_open_ai_or_any_openai_proxy_one_do_not_forget_to_end_with_a_/_the_url
- IMAGE_GENERATION_MODELS_ON=True # true if you use have a proxy server on which you added another model
- AI_API_TOKEN=your_token_here_for_the_ai_part # used for transcription with whisper-1 and for translation with gpt-3.5-turbo-16k (will add feature to change later)
- AI_API_BASE_URL=the_url_for_the_request_open_ai_or_any_openai_proxy_one_do_not_forget_to_end_with_a_/_the_url # the url to get the models above
- AI_IMAGE_API_TOKEN="Your token here for the ai part" # token for the image generation can be the same or different from the one above
- AI_IMAGE_API_BASE_URL="The url for the request open ai or any openai proxy one do not forget to end with a / the url" # url of the api can be the same or different as the one above.
- IMAGE_GENERATION_MODELS_ON=True # true if you use have a proxy server on which you added another model for image gen.
- IMAGE_GENERATION_MODELS=model_name # the name of the model you want only used if IMAGE_GENERATION_MODELS_ON is True
- IMAGE_QUALITY="hd" # dall-e-3
- IMAGE_SIZE="1024x1024" # depend on models
- IMAGE_STYLE="vivid" # dall-e-3
- RUST_LOG="info" # trace, debug, info, warn or error
- NSFW=True # if the bot should honor the nsfw for image if set to true it will if false it will not. (turn it off if you are 100% the model you use for image can't generate nsfw)
- TERM=xterm-256color
- REMOVE_OLD_COMMAND_ON_STARTUP=True # if the bot should remove the old command when it start. recommended to set it for the 1st launch or when updating to a breaking change version
- REMOVE_OLD_COMMAND=True # if the bot should remove the old command when it start. recommended to set it for the 1st launch or when updating to a breaking change version
- DB_TYPE="sqlite"
- SAVE_IMAGE="local/remote/false"
- SAVE_SERVER="imgur/catbox"
- TOKEN="catbox userhash / imgur client id"
volumes:
- ./db/data.db:/kasuki/data.db
- ./db/cache.db:/kasuki/cache.db
Expand Down
Binary file removed data.db
Binary file not shown.
40 changes: 40 additions & 0 deletions json/command.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "name of the command in english no more than 50 char long and no space special char or uppercase",
"desc": "description of the command ",
"dm_command": false,
"nsfw": true,
"perm": false,
"default_permissions": "One of the RemotePermissionType in command_register/command_structure if perm is set to true",
"arg_num": 1,
"args": [
{
"name": "name of the option in english no more than 50 char long and no space special char or uppercase",
"desc": "description of the option ",
"required": true,
"autocomplete": false,
"command_type": "One of the RemoteCommandOptionType in command_register/command_structure",
"localised_args": [
{
"code": "en-US",
"name": "1st duplicate of the name and desc of the option in english after it the other translation",
"desc": "same for description"
}
],
"choices": [
{
"option_choice": "one choice"
},
{
"option_choice": "second choice"
}
]
}
],
"localised": [
{
"code": "en-US",
"name": "1st duplicate of the name and desc of the command in english after it the other translation",
"desc": "same for description"
}
]
}
66 changes: 66 additions & 0 deletions json/command/delete_activity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "delete_activity",
"desc": "Delete an anime activity.",
"dm_command": false,
"nsfw": false,
"perm": true,
"default_permissions": [
{
"permission": "Administrator"
}
],
"arg_num": 2,
"args": [
{
"name": "anime_name",
"desc": "Name of the anime you want to delete as an activity.",
"required": true,
"autocomplete": true,
"command_type": "String",
"localised_args": [
{
"code": "en-US",
"name": "anime_name",
"desc": "Name of the anime you want to delete as an activity."
},
{
"code": "fr",
"name": "nom_de_l_anime",
"desc": "Nom de l'anime que vous voulez supprimer comme activité."
},
{
"code": "de",
"name": "anime_name",
"desc": "Name des Animes, das Sie als Aktivität löschen möchten."
},
{
"code": "ja",
"name": "anime_no_namae",
"desc": "アクティビティとして削除したいアニメの名前。"
}
]
}
],
"localised": [
{
"code": "en-US",
"name": "delete_activity",
"desc": "Delete an anime activity."
},
{
"code": "fr",
"name": "supprimer_activite",
"desc": "Supprimer une activité anime."
},
{
"code": "de",
"name": "aktivitat_loeschen",
"desc": "Löschen Sie eine Anime-Aktivität."
},
{
"code": "ja",
"name": "katsudo_wo_sakujo",
"desc": "アニメ活動を削除します。"
}
]
}
30 changes: 30 additions & 0 deletions json/command/generate_image_pfp_server.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "guild_image",
"desc": "Generate an image using the guild server image and the user pfp.",
"dm_command": false,
"nsfw": false,
"perm": false,
"arg_num": 0,
"localised": [
{
"code": "en-US",
"name": "guild_image",
"desc": "Generate an image using the guild server image and the user pfp."
},
{
"code": "fr",
"name": "image_guilde",
"desc": "Génère une image en utilisant l'image du serveur de guilde et le pfp de l'utilisateur."
},
{
"code": "de",
"name": "gildenbild",
"desc": "Generieren Sie ein Bild mit dem Gilden-Serverbild und dem Benutzer-Pfp."
},
{
"code": "ja",
"name": "ギルド画像",
"desc": "ギルドサーバー画像とユーザーpfpを使用して画像を生成します。"
}
]
}
Loading

0 comments on commit fd432c9

Please sign in to comment.