foukoapi 0.1.0-alpha.1

Cross-platform bot framework in Rust. Write your handlers once, run the same bot on Telegram and Discord with shared accounts, embeds, keyboards and SQLite storage.
Documentation
//! Minimal cross-platform bot. Reply to /ping with "pong".
//!
//! Run it:
//!
//! ```bash
//! TG_TOKEN=... DISCORD_TOKEN=... cargo run --example quickstart
//! ```

use foukoapi::{Bot, Platform, Result};

#[tokio::main]
async fn main() -> Result<()> {
    tracing_subscriber::fmt()
        .with_env_filter(
            tracing_subscriber::EnvFilter::try_from_default_env()
                .unwrap_or_else(|_| "info,foukoapi=debug".into()),
        )
        .init();

    let mut bot = Bot::new();

    if let Ok(token) = std::env::var("TG_TOKEN") {
        bot = bot.add_platform(Platform::telegram(token));
    }
    if let Ok(token) = std::env::var("DISCORD_TOKEN") {
        bot = bot.add_platform(Platform::discord(token));
    }

    bot.command("/ping", |ctx| async move { ctx.reply("pong").await })
        .command(
            "/help",
            |ctx| async move { ctx.reply("hi! try /ping").await },
        )
        .run()
        .await
}