Skip to main content

Crate foukoapi

Crate foukoapi 

Source
Expand description

§FoukoApi

A Rust framework for building cross-platform bots. Write a command once, run it on Telegram, Discord and anything you plug in next.

use foukoapi::{Bot, Platform};

Bot::new()
    .add_platform(Platform::telegram(std::env::var("TG_TOKEN")?))
    .add_platform(Platform::discord(std::env::var("DISCORD_TOKEN")?))
    .command("/help", |ctx| async move {
        ctx.reply("hi! i work everywhere").await
    })
    .run()
    .await

FoukoApi is in early development. Expect the API to evolve until 0.1 lands.

Re-exports§

pub use config::bootstrap_env;
pub use config::DbUrl;
pub use config::EnvState;

Modules§

adapters
Platform adapters.
config
Small config helpers.
util
Small helper utilities shared between adapters, built-in commands and user-defined bots.

Structs§

Accounts
Account-linking helper.
Bot
The main entry point.
Button
One button inside a Keyboard.
Command
A single command: its trigger (/help, /roll, …) and its handler.
Ctx
A lightweight handle to an incoming update.
Embed
A platform-agnostic pretty-printed block.
EmbedField
One labelled row inside an Embed.
Handler
Boxed, type-erased async handler.
Keyboard
A grid of Buttons attached to a message.
MemoryStorage
In-memory, non-persistent storage. Lost on restart.
Platform
A platform the Bot should run on.
Reply
A reply you want to send from a handler: optional text, optional embed, optional keyboard.
SqliteStoragesqlite
Persistent SQLite-backed storage.

Enums§

Error
Top-level error type used across FoukoApi.
PlatformKind
Which chat platform an update came from / should be dispatched to.
TextMatch
How a text-trigger matches an incoming message.

Traits§

Storage
Key-value storage used by FoukoApi (account linking, per-user state, …).

Functions§

open_storage
Open whatever storage FOUKO_DB points at.
open_storage_from
Like open_storage but you get to pass the URL directly.

Type Aliases§

AnyStorage
Ready-to-use storage handle, erased behind an Arc.
ReplyFn
Adapter-provided send callback. Takes a fully built Reply and sends it back through the underlying platform.
Result
Shorthand for std::result::Result<T, foukoapi::Error>.