Files
2026-11-20 15:40:30 +01:00

34 lines
822 B
Go

package signalbot
import (
"context"
"net/http"
"strings"
)
type sendRequest struct {
Number string `json:"number"`
Recipients []string `json:"recipients"`
Message string `json:"message"`
TextMode string `json:"text_mode"`
}
// Send sends a plain-text message. to is a group id ("group.<base64>", see
// Groups), a phone number in E.164 format, or an ACI UUID. The text is sent
// as is: markdown is not interpreted. Send does not retry.
func (c *Client) Send(ctx context.Context, to, text string) error {
if strings.TrimSpace(text) == "" {
return ErrEmptyText
}
acct, err := c.account(ctx)
if err != nil {
return err
}
return c.do(ctx, http.MethodPost, "/v2/send", sendRequest{
Number: acct.id(),
Recipients: []string{to},
Message: text,
TextMode: "normal",
}, nil)
}