docs: README, compose example, integration test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vincent BourdonandClaude Opus 5.5 committed 2026-11-20 15:45:23 +01:00
1 parent 15874f7ecb
commit 45f88378a6
4 files changed
+236

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
# Minimal deployment: the Signal service and an app using signalbot.
services:
signal-api:
image: bbernhard/signal-cli-rest-api:0.101
environment:
- MODE=json-rpc-native # fallback: MODE=json-rpc if native mode is unstable
- JSON_RPC_RECEIVE_MODE=manual # keep messages queued while the app is down
volumes:
- signal-data:/home/.local/share/signal-cli # account keys: losing it means re-linking
restart: unless-stopped
# Only while linking (`signalbot link`), then remove: the API has no authentication.
# ports:
# - "127.0.0.1:8080:8080"
app:
build: .
environment:
- SIGNAL_API_URL=http://signal-api:8080
- SIGNAL_GROUP_ID=group.REPLACE_ME # from `signalbot groups`
depends_on:
- signal-api
restart: unless-stopped
volumes:
signal-data:
+41
View File
@@ -0,0 +1,41 @@
// Command example announces itself in a group, then answers every incoming
// text message with an echo.
//
// SIGNAL_API_URL=http://localhost:8080 SIGNAL_GROUP_ID=group.… go run ./examples
package main
import (
"context"
"errors"
"log"
"os"
"os/signal"
"git.siteop.biz/vincentb99/signalbot"
)
func main() {
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
defer cancel()
client, err := signalbot.New(os.Getenv("SIGNAL_API_URL"))
if err != nil {
log.Fatal(err)
}
if group := os.Getenv("SIGNAL_GROUP_ID"); group != "" {
if err := client.Send(ctx, group, "example bot started"); err != nil {
log.Printf("announce: %v", err)
}
}
// Keep Listen running even if you only publish: it also processes the
// retry receipts that keep group members able to decrypt your messages.
err = client.Listen(ctx, func(ctx context.Context, m signalbot.Message) {
if err := m.Reply(ctx, "echo: "+m.Text); err != nil {
log.Printf("reply: %v", err)
}
})
if err != nil && !errors.Is(err, context.Canceled) {
log.Fatal(err)
}
}