foukoapi 0.1.2-alpha.2

Cross-platform bot framework in Rust: one codebase, many platforms. Shared accounts, embeds, keyboards, economy, i18n and pluggable storage; Telegram and Discord adapters included.
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
}