feat: bot alias reservation + BOT_API.md documentation
- Aliases ending with Bot/bot/_bot reserved for registered bots only - Non-bot users get clear error directing to /v1/bot/register - Bot registration auto-creates alias (@name_bot suffix) - BOT_API.md: full developer guide with endpoints, examples, echo bot - LLM_HELP.md: expanded bot section with update types + Python example Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -100,12 +100,25 @@ async fn register_bot(
|
||||
&token[..token.len().min(20)]
|
||||
);
|
||||
|
||||
// Auto-register bot alias (name must end with Bot or _bot)
|
||||
let bot_alias = if req.name.ends_with("Bot") || req.name.ends_with("_bot") || req.name.ends_with("bot") {
|
||||
req.name.to_lowercase()
|
||||
} else {
|
||||
format!("{}_bot", req.name.to_lowercase())
|
||||
};
|
||||
let alias_key = format!("a:{}", bot_alias);
|
||||
let _ = state.db.aliases.insert(alias_key.as_bytes(), fp.as_bytes());
|
||||
let fp_key = format!("fp:{}", fp);
|
||||
let _ = state.db.aliases.insert(fp_key.as_bytes(), bot_alias.as_bytes());
|
||||
tracing::info!("Bot alias @{} registered for {}", bot_alias, fp);
|
||||
|
||||
Ok(Json(serde_json::json!({
|
||||
"ok": true,
|
||||
"result": {
|
||||
"token": token,
|
||||
"name": req.name,
|
||||
"fingerprint": fp,
|
||||
"alias": format!("@{}", bot_alias),
|
||||
}
|
||||
})))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user