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()
.awaitFoukoApi 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.
- Embed
Field - One labelled row inside an
Embed. - Handler
- Boxed, type-erased async handler.
- Keyboard
- A grid of
Buttons attached to a message. - Memory
Storage - In-memory, non-persistent storage. Lost on restart.
- Platform
- A platform the
Botshould run on. - Reply
- A reply you want to send from a handler: optional text, optional embed, optional keyboard.
- Sqlite
Storage sqlite - Persistent SQLite-backed storage.
Enums§
- Error
- Top-level error type used across FoukoApi.
- Platform
Kind - Which chat platform an update came from / should be dispatched to.
- Text
Match - 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_DBpoints at. - open_
storage_ from - Like
open_storagebut 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
Replyand sends it back through the underlying platform. - Result
- Shorthand for
std::result::Result<T, foukoapi::Error>.