Documentation
¶
Index ¶
- Variables
- func Bool(v bool) *bool
- func Int(v int) *int
- func Int64(v int64) *int64
- func String(v string) *string
- type API
- func (api *API) DeleteAttachment(attachmentId string) error
- func (api *API) GetAttachment(attachmentId string) ([]byte, error)
- func (api *API) GetGroup(groupId string) (GroupResponse, error)
- func (api *API) GetGroups() ([]GroupResponse, error)
- func (api *API) HealthCheck() error
- func (api *API) React(receiver, emoji, targetAuthor string, targetTimestamp int64) error
- func (api *API) ReceiveMessages(ctx context.Context) (<-chan Message, error)
- func (api *API) RemoteDelete(receiver string, timestamp int64) error
- func (api *API) SendMessage(receiver, text string, opts *SendOptions) (Message, error)
- func (api *API) SendReceipt(receiver, receiptType string, timestamp int64) error
- func (api *API) StartTyping(receiver string) error
- func (api *API) StopTyping(receiver string) error
- func (api *API) UpdateContact(recipient, name, expirationInSeconds string) error
- type Authentication
- type BasicAuthentication
- type BearerAuthentication
- type Bot
- func (b *Bot) MarkRead(receiver string, timestamp int64) error
- func (b *Bot) React(receiver, emoji, targetAuthor string, targetTimestamp int64) error
- func (b *Bot) Register(cmd Command)
- func (b *Bot) Send(receiver, text string, opts *SendOptions) (Message, error)
- func (b *Bot) Start() error
- func (b *Bot) StartTyping(receiver string) error
- func (b *Bot) StopTyping(receiver string) error
- type Command
- type CommandFunc
- type Config
- type Context
- type GroupResponse
- type LinkPreview
- type LinkPreviewRequest
- type Message
- type MessageType
- type Quote
- type Reaction
- type ReactionRequest
- type ReceiptRequest
- type RedisStorage
- type RemoteDeleteRequest
- type SQLiteStorage
- type SendMessageRequest
- type SendOptions
- type Storage
- type TypingIndicatorRequest
- type UpdateContactRequest
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("key not found")
ErrNotFound is returned when a key is not found in the storage
Functions ¶
Types ¶
type API ¶
type API struct {
SignalService string
PhoneNumber string
// contains filtered or unexported fields
}
func (*API) DeleteAttachment ¶
Deletes an attachment by its ID from the local storage
func (*API) GetAttachment ¶
Retrieves the raw binary content of an attachment by its ID
func (*API) GetGroup ¶
func (api *API) GetGroup(groupId string) (GroupResponse, error)
Retrieves information about a specific group by its ID
func (*API) GetGroups ¶
func (api *API) GetGroups() ([]GroupResponse, error)
Retrieves the list of groups associated with the phone number
func (*API) HealthCheck ¶
Checks the health of the Signal service by sending a GET request to the /v1/health endpoint
func (*API) ReceiveMessages ¶
Receives messages from via a WebSocket connection and returns a channel of Message objects
func (*API) RemoteDelete ¶
Deletes a message from the recipient's device by specifying the receiver and timestamp
func (*API) SendMessage ¶
func (api *API) SendMessage(receiver, text string, opts *SendOptions) (Message, error)
Sends a message to the specified receiver with optional parameters
func (*API) SendReceipt ¶
Sends a receipt for a message to the specified receiver
func (*API) StartTyping ¶
Starts typing indicator for the specified receiver
func (*API) StopTyping ¶
Stops typing indicator for the specified receiver
func (*API) UpdateContact ¶
Updates a contact's name and/or expiration time for the specified recipient
type Authentication ¶
type BasicAuthentication ¶
BasicAuthentication handles username/password based authentication
func (*BasicAuthentication) ApplyTo ¶
func (auth *BasicAuthentication) ApplyTo(headers map[string]string)
func (*BasicAuthentication) AuthString ¶
func (auth *BasicAuthentication) AuthString() string
type BearerAuthentication ¶
type BearerAuthentication struct {
Token string
}
BearerAuthentication handles token based authentication
func (*BearerAuthentication) ApplyTo ¶
func (auth *BearerAuthentication) ApplyTo(headers map[string]string)
func (*BearerAuthentication) AuthString ¶
func (auth *BearerAuthentication) AuthString() string
type Bot ¶
type Bot struct {
SignalService string
PhoneNumber string
Commands []Command
API *API
Storage Storage // Central storage interface
DownloadAttachments bool
// contains filtered or unexported fields
}
func (*Bot) StartTyping ¶
func (*Bot) StopTyping ¶
type Command ¶
func ReactionTriggered ¶
ReactionTriggered returns a command that only fires when a reaction matching the emojis is received
func RegexTriggered ¶
RegexTriggered returns a command that only fires if the message matches the regex
type CommandFunc ¶
func (CommandFunc) Handle ¶
func (f CommandFunc) Handle(ctx *Context) error
type Config ¶
type Config struct {
SignalService string
PhoneNumber string
Auth Authentication
Storage Storage
DownloadAttachments bool
}
Config holds all parameters to bootstrap a signalbot instance
type GroupResponse ¶
type LinkPreview ¶
type LinkPreviewRequest ¶
type Message ¶
type Message struct {
Source string
SourceNumber *string
SourceUUID string
Timestamp int64
Type MessageType
Text string
Base64Attachments []string
AttachmentsLocalFilenames []string
ViewOnce bool
LinkPreviews []LinkPreview
Group *string
Reaction *Reaction
Mentions []string
Quote *Quote
ReadMessages []json.RawMessage
TargetSentTimestamp *int64
RemoteDeleteTimestamp *int64
UpdatedGroupID *string
RawMessage string
}
func UnmarshalSignalJSON ¶
UnmarshalSignalJSON processes the outer Payload Envelope from the websocket
type MessageType ¶
type MessageType int
const ( SyncMessage MessageType = iota DataMessage EditMessage DeleteMessage ReadMessage GroupUpdateMessage ReactionMessage ContactSyncMessage )
type ReactionRequest ¶
type ReceiptRequest ¶
type RedisStorage ¶
type RedisStorage struct {
// contains filtered or unexported fields
}
func NewRedisStorage ¶
func NewRedisStorage(host string, port int, password string) *RedisStorage
type RemoteDeleteRequest ¶
type SQLiteStorage ¶
type SQLiteStorage struct {
// contains filtered or unexported fields
}
func NewSQLiteStorage ¶
func NewSQLiteStorage(dataSourceName string) (*SQLiteStorage, error)
func (*SQLiteStorage) Delete ¶
func (s *SQLiteStorage) Delete(ctx context.Context, key string) error
type SendMessageRequest ¶
type SendMessageRequest struct {
Message string `json:"message"`
Number string `json:"number"`
Recipients []string `json:"recipients"`
QuoteAuthor *string `json:"quote_author,omitempty"`
QuoteTimestamp *int64 `json:"quote_timestamp,omitempty"`
QuoteMessage *string `json:"quote_message,omitempty"`
Base64Attachments []string `json:"base64_attachments,omitempty"`
LinkPreview *LinkPreviewRequest `json:"link_preview,omitempty"`
Mentions []string `json:"mentions,omitempty"`
EditTimestamp *int64 `json:"edit_timestamp,omitempty"`
ViewOnce *bool `json:"view_once,omitempty"`
}
type SendOptions ¶
type TypingIndicatorRequest ¶
type TypingIndicatorRequest struct {
Recipient string `json:"recipient"`
}