mirror of
https://github.com/Steffo99/patched-porobot.git
synced 2024-12-22 17:44:22 +00:00
temp
This commit is contained in:
parent
ca5760d5e0
commit
d86efd6362
6 changed files with 81 additions and 3 deletions
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -18,5 +18,8 @@
|
||||||
"telegram",
|
"telegram",
|
||||||
"discord",
|
"discord",
|
||||||
"matrix",
|
"matrix",
|
||||||
|
],
|
||||||
|
"rust-analyzer.linkedProjects": [
|
||||||
|
"./Cargo.toml"
|
||||||
]
|
]
|
||||||
}
|
}
|
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -990,6 +990,12 @@ dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "micronfig"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "09d5fa5735feed9ff4d6fc550793ef80d18b90f33f3f89af6176318f295383cd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mime"
|
name = "mime"
|
||||||
version = "0.3.17"
|
version = "0.3.17"
|
||||||
|
@ -1157,6 +1163,7 @@ dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
"md5",
|
"md5",
|
||||||
|
"micronfig",
|
||||||
"pretty_env_logger",
|
"pretty_env_logger",
|
||||||
"rand",
|
"rand",
|
||||||
"regex",
|
"regex",
|
||||||
|
|
|
@ -33,6 +33,7 @@ hmac = { version = "0.12.1", optional = true }
|
||||||
sha2 = { version = "0.10.6", optional = true }
|
sha2 = { version = "0.10.6", optional = true }
|
||||||
# exec
|
# exec
|
||||||
pretty_env_logger = { version = "0.4.0", optional = true }
|
pretty_env_logger = { version = "0.4.0", optional = true }
|
||||||
|
micronfig = { version = "0.1.2", optional = true }
|
||||||
# data
|
# data
|
||||||
serde = { version = "1.0.140", features = ["derive"] }
|
serde = { version = "1.0.140", features = ["derive"] }
|
||||||
serde_json = { version = "1.0.82" }
|
serde_json = { version = "1.0.82" }
|
||||||
|
@ -56,7 +57,7 @@ tokio = { version = "1.20.3", features = ["rt-multi-thread", "macros"] }
|
||||||
[features]
|
[features]
|
||||||
jpg = ["hmac", "sha2", "base64", "hex"]
|
jpg = ["hmac", "sha2", "base64", "hex"]
|
||||||
test = ["tokio"]
|
test = ["tokio"]
|
||||||
exec = ["pretty_env_logger"]
|
exec = ["pretty_env_logger", "micronfig"]
|
||||||
search = ["tantivy"]
|
search = ["tantivy"]
|
||||||
telegram = ["exec", "search", "jpg", "teloxide", "tokio", "md5", "rand"]
|
telegram = ["exec", "search", "jpg", "teloxide", "tokio", "md5", "rand"]
|
||||||
discord = ["exec", "search", "serenity", "tokio", "anyhow"]
|
discord = ["exec", "search", "serenity", "tokio", "anyhow"]
|
||||||
|
|
65
src/config/mod.rs
Normal file
65
src/config/mod.rs
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
//! Module defining configurable values that can be used by the binaries.
|
||||||
|
#![allow(missing_docs)]
|
||||||
|
|
||||||
|
|
||||||
|
/// Configuration required by the `exec` feature.
|
||||||
|
#[cfg(feature = "exec")]
|
||||||
|
pub mod exec {
|
||||||
|
lazy_static::lazy_static! {
|
||||||
|
/// The locale that card data should be downloaded in.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// - `en_US`
|
||||||
|
/// - `it_IT`
|
||||||
|
///
|
||||||
|
pub static ref DATA_DRAGON_LOCALE: String =
|
||||||
|
micronfig::required("DATA_DRAGON_LOCALE");
|
||||||
|
|
||||||
|
/// The set codes for which card data should be downloaded, separated by commas.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// - `set1,set2,set3`
|
||||||
|
/// - `set1`
|
||||||
|
/// - `set1,set2,set3,set4,set5,set6,set6cde,set7`
|
||||||
|
///
|
||||||
|
pub static ref DATA_DRAGON_SET_CODES: Vec<String> =
|
||||||
|
micronfig::required::<String>("DATA_DRAGON_SET_CODES")
|
||||||
|
.split(",").map(|s: &str| s.to_string()).collect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Configuration required by the `jpg` feature.
|
||||||
|
#[cfg(feature = "jpg")]
|
||||||
|
pub mod jpg {
|
||||||
|
lazy_static::lazy_static! {
|
||||||
|
/// Secret key configured in imgproxy.
|
||||||
|
pub static ref POROXY_KEY: Vec<u8> = micronfig::required("POROXY_KEY");
|
||||||
|
|
||||||
|
/// Salt configured in imgproxy.
|
||||||
|
pub static ref POROXY_SALT: String = micronfig::required("POROXY_SALT");
|
||||||
|
|
||||||
|
/// URL where imgproxy can be reached at.
|
||||||
|
pub static ref POROXY_HOST: String = micronfig::required("POROXY_HOST");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Configuration required by the `discord` feature.
|
||||||
|
#[cfg(feature = "discord")]
|
||||||
|
pub mod discord {
|
||||||
|
lazy_static::lazy_static! {
|
||||||
|
/// ID of the guild where commands should be registered in.
|
||||||
|
///
|
||||||
|
/// If not defined, commands are registered globally, and then cached.
|
||||||
|
///
|
||||||
|
/// Useful for development, since guild commands are not cached.
|
||||||
|
pub static ref SERENITY_DEV_GUILD_ID: Option<serenity::model::id::GuildId> = micronfig::optional("SERENITY_DEV_GUILD_ID").map(|s: u64| s.into());
|
||||||
|
|
||||||
|
/// The Discord bot token.
|
||||||
|
pub static ref SERENITY_TOKEN: String = micronfig::required("SERENITY_TOKEN");
|
||||||
|
|
||||||
|
/// The Discord bot app ID.
|
||||||
|
pub static ref SERENITY_APPID: u64 = micronfig::required("SERENITY_APPID");
|
||||||
|
}
|
||||||
|
}
|
|
@ -53,8 +53,7 @@ impl CardArt {
|
||||||
use hmac::Mac;
|
use hmac::Mac;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
let key = env::var("POROXY_KEY")
|
let key = crate::config::jpg::POROXY_KEY;
|
||||||
.expect("POROXY_KEY to be set");
|
|
||||||
let key = hex::decode(key)
|
let key = hex::decode(key)
|
||||||
.expect("POROXY_KEY to be a valid hex code");
|
.expect("POROXY_KEY to be a valid hex code");
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
|
|
||||||
pub mod data;
|
pub mod data;
|
||||||
|
|
||||||
|
#[cfg(feature = "exec")]
|
||||||
|
pub mod config;
|
||||||
|
|
||||||
#[cfg(feature = "search")]
|
#[cfg(feature = "search")]
|
||||||
pub mod search;
|
pub mod search;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue