fix: log full bot tokens + write to data_dir/bot-tokens.txt
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
10
warzone/Cargo.lock
generated
10
warzone/Cargo.lock
generated
@@ -2956,7 +2956,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "warzone-client"
|
||||
version = "0.0.32"
|
||||
version = "0.0.33"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"argon2",
|
||||
@@ -2989,7 +2989,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "warzone-mule"
|
||||
version = "0.0.32"
|
||||
version = "0.0.33"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@@ -2998,7 +2998,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "warzone-protocol"
|
||||
version = "0.0.32"
|
||||
version = "0.0.33"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"bincode",
|
||||
@@ -3023,7 +3023,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "warzone-server"
|
||||
version = "0.0.32"
|
||||
version = "0.0.33"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
@@ -3053,7 +3053,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "warzone-wasm"
|
||||
version = "0.0.32"
|
||||
version = "0.0.33"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"bincode",
|
||||
|
||||
@@ -82,7 +82,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
// Register alias
|
||||
let _ = state.db.aliases.insert(b"a:botfather", botfather_fp.as_bytes());
|
||||
let _ = state.db.aliases.insert(format!("fp:{}", botfather_fp).as_bytes(), b"botfather");
|
||||
tracing::info!("BotFather created: @botfather (token: {}...)", &token[..20]);
|
||||
tracing::info!("BotFather created: @botfather (token: {})", token);
|
||||
} else {
|
||||
tracing::info!("BotFather already exists");
|
||||
}
|
||||
@@ -141,7 +141,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
let _ = state.db.tokens.insert(format!("bot_fp:{}", fp).as_bytes(), token.as_bytes());
|
||||
let _ = state.db.aliases.insert(alias_key.as_bytes(), fp.as_bytes());
|
||||
let _ = state.db.aliases.insert(format!("fp:{}", fp).as_bytes(), alias.as_bytes());
|
||||
tracing::info!("System bot @{} created (token: {}...)", alias, &token[..20]);
|
||||
tracing::info!("System bot @{} created (token: {})", alias, token);
|
||||
fp
|
||||
};
|
||||
|
||||
@@ -157,6 +157,26 @@ async fn main() -> anyhow::Result<()> {
|
||||
}
|
||||
tracing::info!("Loaded {} system bots from {}", bots.len(), bots_path);
|
||||
|
||||
// Write tokens to file for easy access
|
||||
let tokens_path = format!("{}/bot-tokens.txt", cli.data_dir);
|
||||
let mut token_lines = Vec::new();
|
||||
for bot in &bots {
|
||||
let name = bot.get("name").and_then(|v| v.as_str()).unwrap_or("");
|
||||
if name.is_empty() { continue; }
|
||||
let alias = name.to_lowercase();
|
||||
if let Some(fp_bytes) = state.db.aliases.get(format!("a:{}", alias).as_bytes()).ok().flatten() {
|
||||
let fp = String::from_utf8_lossy(&fp_bytes).to_string();
|
||||
if let Some(tok_bytes) = state.db.tokens.get(format!("bot_fp:{}", fp).as_bytes()).ok().flatten() {
|
||||
let tok = String::from_utf8_lossy(&tok_bytes).to_string();
|
||||
token_lines.push(format!("{}={}", alias.to_uppercase(), tok));
|
||||
}
|
||||
}
|
||||
}
|
||||
if !token_lines.is_empty() {
|
||||
let _ = std::fs::write(&tokens_path, token_lines.join("\n") + "\n");
|
||||
tracing::info!("Bot tokens written to {}", tokens_path);
|
||||
}
|
||||
|
||||
// Store bot list in DB for welcome screen
|
||||
let bot_list: Vec<serde_json::Value> = bots.iter().map(|b| {
|
||||
serde_json::json!({
|
||||
|
||||
Reference in New Issue
Block a user