Skip to content

Commit

Permalink
fix: complete config module
Browse files Browse the repository at this point in the history
  • Loading branch information
itsusinn committed Oct 19, 2021
1 parent c82ae61 commit b30e49f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion libs/mesagisto-client
10 changes: 3 additions & 7 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct Config {
#[educe(Default = false)]
pub enabled: bool,
pub nats: NatsConfig,
pub cipher: CipherConfig,
pub telegram: TelegramConfig,
pub proxy: ProxyConfig,
pub target_address_mapper: DashMap<i64, ArcStr>,
Expand Down Expand Up @@ -44,9 +45,10 @@ pub struct ProxyConfig {
pub struct CipherConfig {
#[educe(Default = false)]
pub enabled: bool,
// pattern: "http://{username}:{password}@{host}:{port}"
#[educe(Default = "this-is-an-example-key")]
pub key: String,
#[educe(Default = true)]
pub refuse_plain: bool
}

#[basic_derive]
Expand All @@ -69,9 +71,3 @@ pub struct WebhookConfig {
#[educe(Default = "heroku-app-name.herokuapp.com")]
pub host: String,
}

#[basic_derive]
pub struct BehaviorConfig {}

#[basic_derive]
pub struct FormatConfig {}
10 changes: 7 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ async fn run() -> Result<(), anyhow::Error> {
warn!("若要启用,请修改配置文件。");
return Ok(());
}
CIPHER.init(&"this is an example key".to_string());
CACHE.init();
CIPHER.init(&CONFIG.cipher.key,&CONFIG.cipher.refuse_plain);
info!("Mesagisto-Bot is starting up");
info!("Mesagisto-Bot正在启动");
DB.init(ArcStr::from("tg").some());
Expand All @@ -70,8 +71,11 @@ async fn run() -> Result<(), anyhow::Error> {
}.boxed()
});
SERVER.init(&CONFIG.nats.address).await;
CACHE.init();
let bot = Bot::with_client(CONFIG.telegram.token.clone(), net::client_from_config()).auto_send();

let bot = Bot::with_client(
CONFIG.telegram.token.clone(),
net::client_from_config()
).auto_send();

TG_BOT.init(Arc::new(bot));

Expand Down

0 comments on commit b30e49f

Please sign in to comment.