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 banner::Banner;pub use banner::Palette;pub use banner::Tone;pub use config::bootstrap_env;pub use config::env_file_error;pub use config::env_file_path;pub use config::DbUrl;pub use config::EnvState;
Modules§
- adapters
- Platform adapters.
- banner
- Startup banner: a colorful, human-facing summary printed straight to stdout before the adapters spin up. Logs belong in tracing; this is the shop window, so it uses plain println with hand-rolled ANSI colors.
- config
- Small config helpers.
- genai
genai - OpenAI-compatible generation client: chat, model discovery, image, video and speech generation.
- tunnel
tunnel - Cloudflare quick tunnels for Mini App development and small deployments.
- util
- Small helper utilities shared between adapters, built-in commands and user-defined bots.
- webapp
webapp - Telegram Mini App helpers: server-side validation of
initData.
Structs§
- Accounts
- Account-linking helper.
- Bot
- The main entry point.
- Button
- One button inside a
Keyboard. - Chat
Info - Cross-platform snapshot of the chat/server a command ran in.
- Command
- A single command: its trigger (
/help,/roll, …) and its handler. - Ctx
- A lightweight handle to an incoming update.
- Economy
- An economy handle sharing storage with
Accounts. - Embed
- A platform-agnostic pretty-printed block.
- Embed
Field - One labelled row inside an
Embed. - Handler
- Boxed, type-erased async handler.
- I18n
- A translation catalogue:
key -> (lang -> text). - Keyboard
- A grid of
Buttons attached to a message. - Memory
Storage - In-memory, non-persistent storage. Lost on restart.
- Notifier
- A cloneable handle for pushing messages into chats out of band.
- Platform
- A platform the
Botshould run on. - Presence
- What the bot appears to be doing, shown in the member list and on its profile. Discord renders it natively (“Playing X”, a purple “LIVE” badge for streaming, and so on); platforms without presence (Telegram) ignore it.
- Ranked
Player - One row of a leaderboard.
- Rate
Limit - A rate-limit policy: at most
max_hitsevents perwindow. - Rate
Limiter - A sliding-window rate limiter keyed by arbitrary strings.
- Reply
- A reply you want to send from a handler: optional text, optional embed, optional keyboard.
- Secret
crypto - An AES-256-GCM encryption handle. Cheap to clone.
- Sqlite
Storage sqlite - Persistent SQLite-backed storage.
- Wallet
- A player’s resolved balances.
- XpGain
- What one
Economy::add_xpcall produced.
Enums§
- Decision
- The verdict for a single check.
- Error
- Top-level error type used across FoukoApi.
- Metric
- What
Economy::leaderboardranks on. - Platform
Kind - Which chat platform an update came from / should be dispatched to.
- Presence
Status - The bot’s online dot.
- Text
Match - How a text-trigger matches an incoming message.
Constants§
- FALLBACK_
LANG - The language a catalogue falls back to when a translation is missing.
- XP_
PER_ COIN - XP-per-coin conversion used by
Economy::add_xp.
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>.