feat: Split des packages

This commit is contained in:
Max batleforc 2025-05-27 19:49:29 +02:00
parent d026347897
commit 9ecece1a5b
No known key found for this signature in database
GPG Key ID: 25D243AB4B6AC9E7
24 changed files with 185 additions and 41 deletions

37
Cargo.lock generated
View File

@ -404,15 +404,12 @@ dependencies = [
"chrono",
"clickhouse",
"clickhouse_pool",
"config",
"database",
"poise",
"serde",
"tokio",
"tokio-cron-scheduler",
"toml",
"tool_tracing",
"tracing",
"uuid",
]
[[package]]
@ -524,6 +521,26 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93a719913643003b84bd13022b4b7e703c09342cd03b679c4641c7d2e50dc34d"
[[package]]
name = "cli"
version = "0.1.0"
dependencies = [
"bot",
"chrono",
"clickhouse",
"clickhouse_pool",
"config",
"database",
"poise",
"serde",
"tokio",
"tokio-cron-scheduler",
"toml",
"tool_tracing",
"tracing",
"uuid",
]
[[package]]
name = "clickhouse"
version = "0.13.2"
@ -583,6 +600,18 @@ dependencies = [
"url",
]
[[package]]
name = "config"
version = "0.1.0"
dependencies = [
"database",
"poise",
"serde",
"toml",
"tool_tracing",
"tracing",
]
[[package]]
name = "core-foundation"
version = "0.9.4"

View File

@ -2,28 +2,30 @@
[workspace]
resolver = '2'
members = [
'apps/bot',
'libs/tool_tracing',
'libs/clickhouse_pool',
'libs/database',
'apps/cli',
'libs/tool_tracing',
'libs/clickhouse_pool',
'libs/database',
'libs/bot',
'libs/config',
]
[workspace.dependencies]
poise = { git = "https://github.com/serenity-rs/poise", branch = "current" }
poise = { git = 'https://github.com/serenity-rs/poise', branch = 'current' }
tokio = { version = '1.45.0', features = [
'macros',
'rt-multi-thread',
'io-std',
'macros',
'rt-multi-thread',
'io-std',
] }
serde = '1.0'
tracing = '0.1'
serde_json = '1.0'
clickhouse = { version = '0.13', features = ['native-tls', 'uuid', 'chrono'] }
uuid = { version = "1.16", features = ["serde", "v4"] }
chrono = { version = "0.4.41", features = ["serde"] }
uuid = { version = '1.16', features = ['serde', 'v4'] }
chrono = { version = '0.4.41', features = ['serde'] }
[profile.release]
lto = true
[patch.crates-io]
serenity = { git = "https://github.com/serenity-rs/serenity", branch = "current" }
serenity = { git = 'https://github.com/serenity-rs/serenity', branch = 'current' }

View File

@ -24,7 +24,6 @@
- [ ] [ADMIN] trivial add-question : Ajout de question + réponse ou X réponse
- [ ] [ADMIN] trivial del-question : Suppression de question
- [ ] [ADMIN] trivial load-question : Charge un fichier/lien de question
- [ ] [ADMIN] trivial choose-chan : Choix du channel
- [ ] trivial scoreboard : Scoreboard
- [ ] trivial score : Score d'une personne par défaut le sien
- [ ] trivial top : Top X par défaut 3

View File

@ -1,5 +1,5 @@
[package]
name = "bot"
name = "cli"
version = "0.1.0"
edition = "2021"
@ -20,5 +20,7 @@ tokio-cron-scheduler = { version = "0.14", features = [
"tracing-subscriber",
"signal",
] }
config = { path = "../../libs/config" }
bot = { path = "../../libs/bot" }
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -1,8 +1,8 @@
{
"name": "bot",
"name": "cli",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/bot/src",
"sourceRoot": "apps/cli/src",
"targets": {
"build": {
"cache": true,
@ -11,7 +11,7 @@
"{options.target-dir}"
],
"options": {
"target-dir": "dist/target/bot"
"target-dir": "dist/target/cli"
},
"configurations": {
"production": {
@ -26,7 +26,7 @@
"{options.target-dir}"
],
"options": {
"target-dir": "dist/target/bot"
"target-dir": "dist/target/cli"
},
"configurations": {
"production": {
@ -41,7 +41,7 @@
"{options.target-dir}"
],
"options": {
"target-dir": "dist/target/bot"
"target-dir": "dist/target/cli"
}
},
"run": {
@ -50,7 +50,7 @@
"{options.target-dir}"
],
"options": {
"target-dir": "dist/target/bot"
"target-dir": "dist/target/cli"
},
"configurations": {
"production": {

View File

@ -2,10 +2,6 @@ use bot::start_bot;
use config::parse_local_config;
use tracing::{error, info};
pub mod bot;
pub mod config;
pub mod dotenv;
#[tokio::main]
async fn main() {
println!(include_str!("banner.art"));

17
libs/bot/Cargo.toml Normal file
View File

@ -0,0 +1,17 @@
[package]
name = "bot"
version = "0.1.0"
edition = "2021"
[dependencies]
poise = { workspace = true }
tokio = { workspace = true }
serde = { workspace = true }
tracing = { workspace = true }
clickhouse_pool = { path = "../../libs/clickhouse_pool" }
clickhouse = { workspace = true }
chrono = { workspace = true }
config = { path = "../../libs/config" }
database = { path = "../../libs/database" }
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

43
libs/bot/project.json Normal file
View File

@ -0,0 +1,43 @@
{
"name": "bot",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "libs/bot/src",
"targets": {
"build": {
"executor": "@monodon/rust:check",
"outputs": [
"{options.target-dir}"
],
"options": {
"target-dir": "dist/target/bot"
}
},
"test": {
"cache": true,
"executor": "@monodon/rust:test",
"outputs": [
"{options.target-dir}"
],
"options": {
"target-dir": "dist/target/bot"
},
"configurations": {
"production": {
"release": true
}
}
},
"lint": {
"cache": true,
"executor": "@monodon/rust:lint",
"outputs": [
"{options.target-dir}"
],
"options": {
"target-dir": "dist/target/bot"
}
}
},
"tags": []
}

View File

@ -1,4 +1,4 @@
use crate::bot::{Data, Error};
use crate::{Data, Error};
use poise::serenity_prelude::{self as serenity, ActivityData};
use tracing::info;

View File

@ -2,7 +2,7 @@ use clickhouse_pool::traits::Model;
use database::guild::Guild;
use tracing::{info, warn};
use crate::bot::{Context, Error};
use crate::{Context, Error};
/// Check if the guild has been initialized, if it is check if user is in list of admins
/// If not, check the user's permissions

View File

@ -7,7 +7,7 @@ use tracing::info;
use trivia::trivia;
use utility::{age::age, help::help, server::servers};
use crate::config::Config;
use config::Config;
pub mod event;
pub mod helper;

View File

@ -1,5 +1,5 @@
use crate::bot::helper::is_user_admin_right;
use crate::bot::{Context, Error};
use crate::helper::is_user_admin_right;
use crate::{Context, Error};
use clickhouse_pool::traits::Model;
use database::trivial::{Trivial, TrivialRewardKind};
use poise::serenity_prelude::{Channel, Role};

View File

@ -1,5 +1,5 @@
use crate::bot::helper::is_user_admin_right;
use crate::bot::{Context, Error};
use crate::helper::is_user_admin_right;
use crate::{Context, Error};
use clickhouse_pool::traits::Model;
use database::trivial::Trivial;
use poise::serenity_prelude;

View File

@ -1,5 +1,5 @@
use crate::bot::helper::is_user_admin_right;
use crate::bot::{Context, Error};
use crate::helper::is_user_admin_right;
use crate::{Context, Error};
use clickhouse_pool::traits::Model;
use database::trivial::Trivial;
use poise::{

View File

@ -2,7 +2,7 @@ pub mod config;
pub mod create;
pub mod list;
use crate::bot::{Context, Error};
use crate::{Context, Error};
use config::config;
use create::create;
use list::list;

View File

@ -1,4 +1,4 @@
use crate::bot::{Context, Error};
use crate::{Context, Error};
use poise::serenity_prelude as serenity;
use tracing::instrument;

View File

@ -1,4 +1,4 @@
use crate::bot::{Context, Error};
use crate::{Context, Error};
use poise::builtins::PrettyHelpConfiguration;
use tracing::instrument;

View File

@ -1,4 +1,4 @@
use crate::bot::{Context, Error};
use crate::{Context, Error};
use tracing::instrument;
/// Lists all servers the bot is in

13
libs/config/Cargo.toml Normal file
View File

@ -0,0 +1,13 @@
[package]
name = "config"
version = "0.1.0"
edition = "2021"
[dependencies]
poise = { workspace = true }
serde = { workspace = true }
database = { path = "../../libs/database" }
tool_tracing = { path = "../../libs/tool_tracing" }
toml = "0.8"
tracing = { workspace = true }
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

43
libs/config/project.json Normal file
View File

@ -0,0 +1,43 @@
{
"name": "config",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "libs/config/src",
"targets": {
"build": {
"executor": "@monodon/rust:check",
"outputs": [
"{options.target-dir}"
],
"options": {
"target-dir": "dist/target/config"
}
},
"test": {
"cache": true,
"executor": "@monodon/rust:test",
"outputs": [
"{options.target-dir}"
],
"options": {
"target-dir": "dist/target/config"
},
"configurations": {
"production": {
"release": true
}
}
},
"lint": {
"cache": true,
"executor": "@monodon/rust:lint",
"outputs": [
"{options.target-dir}"
],
"options": {
"target-dir": "dist/target/config"
}
}
},
"tags": []
}

View File

@ -4,7 +4,7 @@ use serde::Deserialize;
use std::{env, fs::read_to_string, path::PathBuf};
use tool_tracing::tracing_kind::Tracing;
use crate::dotenv;
pub mod dotenv;
const BOT_NAME: &str = "BOT_NAME";
const BOT_TOKEN: &str = "BOT_TOKEN";