v0.0.27: TG-compatible bots — plaintext send, numeric IDs, webhooks, BotFather
Bot compatibility: - Clients send plaintext bot_message to bot aliases (no E2E encryption) - Numeric chat_id: fp_to_numeric_id() deterministic hash, accept string/number - Webhook delivery: POST updates to bot's webhook URL (async, fire-and-forget) - getUpdates timeout raised to 50s (was 30, TG uses 50) - parse_mode HTML rendered in web client - E2E bot registration: optional seed + bundle for encrypted bot sessions BotFather + instance control: - --enable-bots CLI flag (default: disabled) - BotFather auto-created on first start (@botfather alias) - Bot ownership: owner fingerprint stored in bot_info - All bot endpoints return 403 when disabled Bot Bridge: - tools/bot-bridge.py: TG-compatible proxy for unmodified TG bots - Translates chat_id int↔string, proxies getUpdates/sendMessage - README with python-telegram-bot and Telegraf examples Test fixes: - Updated tests for ETH address display in header/messages Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -88,6 +88,7 @@ pub struct AppState {
|
||||
pub dedup: DedupTracker,
|
||||
pub active_calls: Arc<Mutex<HashMap<String, CallState>>>,
|
||||
pub federation: Option<crate::federation::FederationHandle>,
|
||||
pub bots_enabled: bool,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
@@ -99,6 +100,7 @@ impl AppState {
|
||||
dedup: DedupTracker::new(),
|
||||
active_calls: Arc::new(Mutex::new(HashMap::new())),
|
||||
federation: None,
|
||||
bots_enabled: false,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -188,6 +190,21 @@ impl AppState {
|
||||
// 3. Queue in local DB
|
||||
let key = format!("queue:{}:{}", to_fp, uuid::Uuid::new_v4());
|
||||
let _ = self.db.messages.insert(key.as_bytes(), message);
|
||||
|
||||
// 4. Try bot webhook delivery (async, does not block the caller)
|
||||
{
|
||||
let state = self.clone();
|
||||
let fp = to_fp.to_string();
|
||||
let queue_key = key.clone();
|
||||
let msg = message.to_vec();
|
||||
tokio::spawn(async move {
|
||||
if crate::routes::bot::try_bot_webhook(&state, &fp, &msg).await {
|
||||
// Webhook accepted -- remove from offline queue
|
||||
let _ = state.db.messages.remove(queue_key.as_bytes());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user