Documentation ¶
Overview ¶
Package signal provides a minimal wrapper for the signal-cli functionality and data types that we need.
Index ¶
- Variables
- func Exec(args ...string) ([]byte, error)
- func GetSignalAvatarsFolder() (string, error)
- func GetSignalFolder() (string, error)
- type Attachment
- type CallMessage
- type DataMessage
- type Envelope
- type ErrorCallback
- type GroupInfo
- type Message
- type MessageCallback
- type MockSignal
- func (ms *MockSignal) Close()
- func (ms *MockSignal) Receive() error
- func (ms *MockSignal) ReceiveForever()
- func (ms *MockSignal) RequestGroupInfo() ([]SignalGroupInfo, error)
- func (ms *MockSignal) Send(dest, msg string) (int64, error)
- func (ms *MockSignal) SendDbus(dest, msg string, attachments ...string) (int64, error)
- func (ms *MockSignal) SendGroupDbus(groupID, msg string, attachments ...string) (int64, error)
- func (ms *MockSignal) Version() (string, error)
- type ReceiptCallback
- type ReceiptMessage
- type ReceivedCallback
- type SentCallback
- type SentMessage
- type Signal
- func (s *Signal) Close()
- func (s *Signal) Daemon() error
- func (s *Signal) GetContactList() ([]*SignalContact, error)
- func (s *Signal) GetGroupList() ([]*SignalGroup, error)
- func (s *Signal) GetRecipientStore() (*SignalRecipientStore, error)
- func (s *Signal) GetUserData() (*SignalUserData, error)
- func (s *Signal) Link(deviceName string) error
- func (s *Signal) OnError(callback ErrorCallback)
- func (s *Signal) OnMessage(callback MessageCallback)
- func (s *Signal) OnReceipt(callback ReceiptCallback)
- func (s *Signal) OnReceived(callback ReceivedCallback)
- func (s *Signal) OnSent(callback SentCallback)
- func (s *Signal) ProcessWire(wire []byte) error
- func (s *Signal) Receive() error
- func (s *Signal) ReceiveForever()
- func (s *Signal) RequestGroupInfo() ([]SignalGroupInfo, error)
- func (s *Signal) Send(dest, msg string) (int64, error)
- func (s *Signal) SendDbus(dest, msg string, attachments ...string) (int64, error)
- func (s *Signal) SendGroupDbus(groupID, msg string, attachments ...string) (int64, error)
- func (s *Signal) Version() (string, error)
- type SignalContact
- type SignalGroup
- type SignalGroupInfo
- type SignalGroupMember
- type SignalRecipient
- type SignalRecipientStore
- type SignalUserData
- type SyncMessage
Constants ¶
This section is empty.
Variables ¶
var SignalAttachmentsDir string = fmt.Sprintf("%s/attachments", SignalDir)
var SignalAvatarsDir string = fmt.Sprintf("%s/avatars", SignalDir)
var SignalDataDir string = fmt.Sprintf("%s/data", SignalDir)
var SignalDir string = ".local/share/signal-cli"
SignalDir is where signal-cli saves its local data
Functions ¶
func Exec ¶
Exec invokes signal-cli with the supplied args and returns the bytes that writes to stdout
func GetSignalAvatarsFolder ¶
GetSignalAvatarsFolder returns the user's signal-cli avatars folder
func GetSignalFolder ¶
GetSignalFolder returns the user's signal-cli local storage
Types ¶
type Attachment ¶
type CallMessage ¶
type CallMessage interface{}
type DataMessage ¶
type DataMessage struct { Timestamp int64 `json:"timestamp"` Message string `json:"message"` ExpiresInSeconds int64 `json:"expiresInSeconds"` Attachments []*Attachment `json:"attachments"` GroupInfo *GroupInfo `json:"groupInfo"` }
type Envelope ¶
type Envelope struct { Source string `json:"source"` Timestamp int64 `json:"timestamp"` IsReceipt bool `json:"isReceipt"` SyncMessage *SyncMessage `json:"syncMessage"` CallMessage *CallMessage `json:"callMessage"` ReceiptMessage *ReceiptMessage `json:"receiptMessage"` DataMessage *DataMessage `json:"dataMessage"` SourceDevice int `json:"sourceDevice"` }
type ErrorCallback ¶
type ErrorCallback func(error)
type MessageCallback ¶
type MockSignal ¶
type MockSignal struct { *Signal // contains filtered or unexported fields }
MockSignal implements siggo's SignalAPI interface without actually calling signal-cli for anything
func NewMockSignal ¶
func NewMockSignal(userNumber string, exampleData []byte) *MockSignal
func (*MockSignal) Close ¶
func (ms *MockSignal) Close()
func (*MockSignal) Receive ¶
func (ms *MockSignal) Receive() error
func (*MockSignal) ReceiveForever ¶
func (ms *MockSignal) ReceiveForever()
func (*MockSignal) RequestGroupInfo ¶
func (ms *MockSignal) RequestGroupInfo() ([]SignalGroupInfo, error)
func (*MockSignal) Send ¶
func (ms *MockSignal) Send(dest, msg string) (int64, error)
Send just sends a fake message, by putting it on the "wire"
func (*MockSignal) SendDbus ¶
func (ms *MockSignal) SendDbus(dest, msg string, attachments ...string) (int64, error)
func (*MockSignal) SendGroupDbus ¶
func (ms *MockSignal) SendGroupDbus(groupID, msg string, attachments ...string) (int64, error)
func (*MockSignal) Version ¶
func (ms *MockSignal) Version() (string, error)
Version just returns the last known compatible version of signal-cli
type ReceiptCallback ¶
type ReceiptMessage ¶
type ReceivedCallback ¶
type SentCallback ¶
type SentMessage ¶
type SentMessage struct { Timestamp int64 `json:"timestamp"` Message string `json:"message"` ExpiresInSeconds int64 `json:"expiresInSeconds"` Attachments []*Attachment `json:"attachments"` GroupInfo *GroupInfo `json:"groupInfo"` Destination string `json:"destination"` Mentions interface{} `json:"mentions"` ViewOnce bool `json:"viewOnce"` }
type Signal ¶
type Signal struct {
// contains filtered or unexported fields
}
Signal represents a signal-cli session for a given user. It can be run in daemon mode by calling the `Daemon` method. It can also be used to send and receive manually using `Receive` and `Send`.
func (*Signal) GetContactList ¶
func (s *Signal) GetContactList() ([]*SignalContact, error)
GetContactList attempts to read an existing contact list from the signal user directory.
func (*Signal) GetGroupList ¶
func (s *Signal) GetGroupList() ([]*SignalGroup, error)
GetGroupList attempts to read an existing contact list from the signal user directory.
func (*Signal) GetRecipientStore ¶
func (s *Signal) GetRecipientStore() (*SignalRecipientStore, error)
GetRecipientStore gets the recipient store. This is where the contacts list is kept in signal-cli >= 0.8.2
func (*Signal) GetUserData ¶
func (s *Signal) GetUserData() (*SignalUserData, error)
GetUserData returns the user data for the current user. this is where the contact list is kept for signal-cli < 0.8.2
func (*Signal) OnError ¶
func (s *Signal) OnError(callback ErrorCallback)
OnError registers a callback to be executed whenever an error occurs.
func (*Signal) OnMessage ¶
func (s *Signal) OnMessage(callback MessageCallback)
OnMessage registers a callback to be executed upon any incoming message of any kind (that we know how to process).
func (*Signal) OnReceipt ¶
func (s *Signal) OnReceipt(callback ReceiptCallback)
OnReceipt registers a callback to be executed whenever a message receipt (for example a Read receipt or a Delivery receipt) is received.
func (*Signal) OnReceived ¶
func (s *Signal) OnReceived(callback ReceivedCallback)
OnReceived registers a callback to be executed whenver an incoming message is received.
func (*Signal) OnSent ¶
func (s *Signal) OnSent(callback SentCallback)
OnSent registers a callback to be executed whenver a sent message appears on the wire (currently, this is when a different linked device sends a message).
func (*Signal) ProcessWire ¶
ProcessWire processes a single wire message, executing any callbacks we have registered.
func (*Signal) ReceiveForever ¶
func (s *Signal) ReceiveForever()
ReceiveForever receives contiuously. WARNING: this will continuously start and stop the JVM and is not recommended unless you want to simulate the Electon app's recource useage.
func (*Signal) RequestGroupInfo ¶
func (s *Signal) RequestGroupInfo() ([]SignalGroupInfo, error)
RequestGroupInfo requests info for all groups from the Signal network
func (*Signal) Send ¶
Send transmits a message to the specified number Destination is a phone number with country code. signal-cli likes to have a `+` before the number, so we add one if it isn't there.
func (*Signal) SendDbus ¶
SendDbus does the same thing as Send but it goes through a running daemon. Returns the message ID
func (*Signal) SendGroupDbus ¶
SendGroupDbus does the same thing as SendDbus but to a group
type SignalContact ¶
type SignalContact struct { Name string `json:"name"` Number string `json:"number"` Color string `json:"color"` MessageExpirationTime int `json:"messageExpirationTime"` ProfileKey string `json:"profileKey"` Blocked bool `json:"blocked"` InboxPosition *int `json:"inboxPosition"` Archived bool `json:"archived"` }
SignalContact is the data signal-cli saves for each contact in SignalDataDir/<phonenumber>. This structure no longer exists as of signal-cli >= 0.8.2
type SignalGroup ¶
type SignalGroup struct { GroupID string `json:"groupId"` MasterKey string `json:"masterKey"` Blocked bool `json:"blocked"` PermissionDenied bool `json:"permissionDenied"` }
SignalGroup is the data that signal-cli saves for each group in SignalDataDir/<phonenumber>
type SignalGroupInfo ¶
type SignalGroupInfo struct { ID string `json:"id"` Name string `json:"name"` IsMember bool `json:"isMember"` IsBlocked bool `json:"isBlocked"` Description string `json:"description"` Members []SignalGroupMember `json:"members"` Admins []SignalGroupMember `json:"admins"` PendingMembers []interface{} `json:"pendingMembers"` RequestingMembers []interface{} `json:"requestingMembers"` GroupInviteLink interface{} `json:"groupInviteLink"` PermissionAddMember string `json:"permissionAddMember"` PermissionEditDetails string `json:"permissionEditDetails"` PermissionSendMessage string `json:"permissionSendMessage"` }
SignalGroupInfo is the data that is retrived for each group when we call `signal-cli listGroups` As far as I know right now that is the only way to get the group names. They don't appear to be saved in signal-cli's data.
type SignalGroupMember ¶
SignalGroupMember is a member of a signal group
type SignalRecipient ¶
type SignalRecipient struct { ID int `json:"id"` Number string `json:"number"` UUID string `json:"uuid"` Profile interface{} `json:"profile"` ProfileKey string `json:"profileKey"` ProfileKeyCredential interface{} `json:"profileKeyCredential"` Contact struct { Name string `json:"name"` Color string `json:"color"` MessageExpirationTime int `json:"messageExpirationTime"` Blocked bool `json:"blocked"` Archived bool `json:"archived"` } `json:"contact"` }
SignalRecipient is the format used in the `recipients-store` file.
func (*SignalRecipient) AsContact ¶
func (r *SignalRecipient) AsContact() *SignalContact
type SignalRecipientStore ¶
type SignalRecipientStore struct {
Recipients []*SignalRecipient `json:"recipients"`
}
SignalRecipientStore
func (*SignalRecipientStore) AsContacts ¶
func (r *SignalRecipientStore) AsContacts() []*SignalContact
type SignalUserData ¶
type SignalUserData struct { ContactStore struct { Contacts []*SignalContact `json:"contacts"` } `json:"contactStore"` GroupStore struct { Groups []*SignalGroup `json:"groups"` } `json:"groupStore"` }
SignalUserData is the data signal saves for a given user in SignalDataDir/<phonenumber>
type SyncMessage ¶
type SyncMessage struct { SentMessage *SentMessage `json:"sentMessage"` Type interface{} `json:"type"` ReadMessages interface{} `json:"readMessages"` }