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 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.
genaigenai
OpenAI-compatible generation client: chat, model discovery, image, video and speech generation.
tunneltunnel
Cloudflare quick tunnels for Mini App development and small deployments.
util
Small helper utilities shared between adapters, built-in commands and user-defined bots.
webappwebapp
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.
ChatInfo
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.
EmbedField
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.
MemoryStorage
In-memory, non-persistent storage. Lost on restart.
Notifier
A cloneable handle for pushing messages into chats out of band.
Platform
A platform the Bot should 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.
RankedPlayer
One row of a leaderboard.
RateLimit
A rate-limit policy: at most max_hits events per window.
RateLimiter
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.
Secretcrypto
An AES-256-GCM encryption handle. Cheap to clone.
SqliteStoragesqlite
Persistent SQLite-backed storage.
Wallet
A player’s resolved balances.
XpGain
What one Economy::add_xp call produced.

Enums§

Decision
The verdict for a single check.
Error
Top-level error type used across FoukoApi.
Metric
What Economy::leaderboard ranks on.
PlatformKind
Which chat platform an update came from / should be dispatched to.
PresenceStatus
The bot’s online dot.
TextMatch
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_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>.