Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMessageNotifierClosed = errors.New("notifier is closed")
ErrMessageNotifierClosed is returned when handlers are no longer accepting work.
var ErrMessageTypeUnknown = errors.New("message type is unknown")
ErrMessageTypeUnknown is returned if message type (string) is not known.
Functions ¶
func InitNotifier ¶ added in v0.3.0
func InitNotifier(ctx context.Context) (*MessageNotifier, MessageNotifierTrigger)
Types ¶
type Attachment ¶
type Attachment struct {
ContentType string `json:"contentType"`
ID string `json:"id"`
Filename *string `json:"filename"`
Size int `json:"size"`
Width *int `json:"width"`
Height *int `json:"height"`
Caption *string `json:"caption"`
UploadTimestamp *int64 `json:"uploadTimestamp"`
}
Attachment defines the attachment structure of a message.
type Client ¶
type Client struct {
MessageNotifier *MessageNotifier
// contains filtered or unexported fields
}
Client represents the Signal API client, and is returned by the New() function.
func New ¶
New creates a new Signal API client and returns it. An error is returned if a websocket fails to open with the Signal's API /v1/receive.
type DataMessage ¶
type DataMessage struct {
Timestamp int64 `json:"timestamp"`
Message *string `json:"message"`
ExpiresInSeconds int `json:"expiresInSeconds"`
ViewOnce bool `json:"viewOnce"`
GroupInfo *struct {
GroupID string `json:"groupId"`
GroupName string `json:"groupName"`
Revision int64 `json:"revision"`
Type string `json:"type"`
} `json:"groupInfo,omitempty"`
Quote *struct {
ID int `json:"id"`
Author string `json:"author"`
AuthorNumber string `json:"authorNumber"`
AuthorUUID string `json:"authorUuid"`
Text string `json:"text"`
Attachments []Attachment `json:"attachments"`
} `json:"quote,omitempty"`
Mentions []struct {
Name string `json:"name"`
Number string `json:"number"`
UUID string `json:"uuid"`
Start int `json:"start"`
Length int `json:"length"`
} `json:"mentions,omitempty"`
Sticker *struct {
PackID string `json:"packId"`
StickerID int `json:"stickerId"`
} `json:"sticker,omitempty"`
Attachments []Attachment `json:"attachments,omitempty"`
RemoteDelete *struct {
Timestamp int64 `json:"timestamp"`
} `json:"remoteDelete,omitempty"`
}
DataMessage represents a data message.
type Envelope ¶
type Envelope struct {
Source string `json:"source"`
SourceNumber string `json:"sourceNumber"`
SourceUUID string `json:"sourceUuid"`
SourceName string `json:"sourceName"`
SourceDevice int `json:"sourceDevice"`
Timestamp int64 `json:"timestamp"`
ReceiptMessage *ReceiptMessage `json:"receiptMessage,omitempty"`
TypingMessage *TypingMessage `json:"typingMessage,omitempty"`
DataMessage *DataMessage `json:"dataMessage,omitempty"`
SyncMessage *struct{} `json:"syncMessage,omitempty"`
}
Envelope represents a message envelope.
type Message ¶
Message defines the message structure received from the Signal API.
func (Message) MessageTypes ¶
func (m Message) MessageTypes() []MessageType
MessageTypes returns the types of a message.
func (Message) MessageTypesStrings ¶
MessageTypes returns the types of a message encoded as a string.
type MessageNotifier ¶ added in v0.3.0
type MessageNotifier struct {
// contains filtered or unexported fields
}
func (*MessageNotifier) RegisterHandler ¶ added in v0.3.0
func (u *MessageNotifier) RegisterHandler(_ context.Context, handler handleable)
type MessageNotifierPayload ¶ added in v0.3.0
type MessageNotifierPayload struct {
Message Message
}
type MessageNotifierTrigger ¶ added in v0.3.0
type MessageNotifierTrigger func(ctx context.Context, payload MessageNotifierPayload) error
type MessageType ¶
type MessageType uint8
MessageType represents a type of a message.
const ( MessageTypeUnknown MessageType = iota // MessageTypeReceipt represents a message that has a receipt. MessageTypeReceipt // MessageTypeTyping represents a message that has a typing. MessageTypeTyping // MessageTypeData represents a message that has data. MessageTypeData // MessageTypeDataMessage represents a message that has data and has a message. MessageTypeDataMessage // MessageTypeSync represents a message that has a sync. MessageTypeSync )
func AllMessageTypes ¶
func AllMessageTypes() []MessageType
AllMessageTypes returns all valid message types.
func ParseMessageType ¶
func ParseMessageType(mt string) (MessageType, error)
ParseMessageType parses a message type given its representation as a string.
func (MessageType) String ¶
func (mt MessageType) String() string
String returns the string representation of a message type.
type ReceiptMessage ¶
type ReceiptMessage struct {
When int64 `json:"when"`
IsDelivery bool `json:"isDelivery"`
IsRead bool `json:"isRead"`
IsViewed bool `json:"isViewed"`
Timestamps []int64 `json:"timestamps"`
}
ReceiptMessage represents a receipt message.
type TypingMessage ¶
TypingMessage represents a typing message.