Skip to content

crabtalk/crabtalk-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crabtalk-client

Starter template for building a client service with crabtalk-command.

This example provides a minimal Discord bot that connects to the crabtalk daemon over a Unix domain socket and forwards messages to an agent.

Structure

src/
  bin/main.rs   CLI entry point (clap App)
  lib.rs        Module declarations
  cmd.rs        Service definition (#[command] + Discord bot)

Key concepts

#[command(kind = "client")] generates service management subcommands (start, stop, run, logs) and a DiscordCommand::start() entry point.

The struct implements an inherent async fn run(&self) method which the macro calls on run — this is the client's main loop.

Setup

  1. Create a Discord bot at https://discord.com/developers/applications
  2. Enable the Message Content intent
  3. Set the DISCORD_TOKEN environment variable

Usage

Make sure the crabtalk daemon is running, then:

# Run directly
DISCORD_TOKEN=your-token cargo run -- run

# Install as a launchd/systemd service
DISCORD_TOKEN=your-token cargo run -- start

# View logs
cargo run -- logs

# Stop
cargo run -- stop

How it works

The bot:

  1. Listens for messages that mention it or are sent in DMs
  2. Opens a UDS connection to ~/.crabtalk/run/crabtalk.sock
  3. Sends a StreamMsg to the default agent
  4. Accumulates text chunks from the streamed response
  5. Sends the full reply back to Discord

Building your own

  1. Clone this repo
  2. Rename the package in Cargo.toml
  3. Replace the Discord bot logic in Discord::run() with your own client
  4. Update the #[command] name

About

Template client of CrabTalk

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages