package meowlib import ( "fmt" "time" ) type Contact struct { Name string `json:"name,omitempty"` ContactPublicKey string `json:"contact_public_key,omitempty"` EncryptionPublicKey string `json:"encryption_public_key,omitempty"` LookupPublicKey string `json:"lookup_public_key,omitempty"` PullServers []Server `json:"pull_servers,omitempty"` } type Peer struct { Name string `json:"name,omitempty"` Me KeyPair `json:"me,omitempty"` Contact Contact `json:"contact,omitempty"` Visible bool `json:"visible,omitempty"` VisiblePassword string `json:"visible_password,omitempty"` PasswordType string `json:"password_type,omitempty"` Blocked bool `json:"blocked,omitempty"` MessageNotification string `json:"message_notification,omitempty"` OnionMode bool `json:"onion_mode,omitempty"` Conversation []InternalMessage `json:"convdersation,omitempty"` LastMessage time.Time `json:"last_message,omitempty"` EncryptionKp KeyPair `json:"conversation_kp,omitempty"` LookupKp KeyPair `json:"lookup_kp,omitempty"` } type PeerList []Peer type Group struct { Name string `json:"name,omitempty"` Members []Contact `json:"members,omitempty"` } func (pl *PeerList) GetFromPublicKey(publickey string) *Peer { for _, peer := range *pl { if peer.Contact.ContactPublicKey == publickey { return &peer } } return nil } func (pl *PeerList) GetFromName(name string) *Peer { for _, peer := range *pl { if peer.Contact.Name == name { return &peer } } return nil } func (peer *Peer) SendText(text string) { im := CreateText(*peer, text) fmt.Println(im.MessageData.Destination) }