From 22f6125e36d684c452672c5fbfd9c9f11c28b50b Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 21 Jul 2019 21:34:50 -0400 Subject: [PATCH] Move more types into types.go and general cleanup --- keybase.go | 37 +------------------------------------ types.go | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/keybase.go b/keybase.go index 680603c..a84c892 100644 --- a/keybase.go +++ b/keybase.go @@ -17,41 +17,6 @@ const ( CHAT string = "chat" ) -// Keybase holds basic information about the local Keybase executable -type Keybase struct { - Path string - Username string - LoggedIn bool - Version string -} - -// Chat holds basic information about a specific conversation -type Chat struct { - keybase *Keybase - Channel Channel -} - -type chat interface { - Send(message ...string) (ChatAPI, error) - Edit(messageId int, message ...string) (ChatAPI, error) - React(messageId int, reaction string) (ChatAPI, error) - Delete(messageId int) (ChatAPI, error) -} - -type keybase interface { - NewChat(channel Channel) Chat - Run(handler func(ChatAPI), options ...RunOptions) - ChatList() ([]conversation, error) - loggedIn() bool - username() string - version() string -} - -type status struct { - Username string `json:"Username"` - LoggedIn bool `json:"LoggedIn"` -} - // NewKeybase returns a new Keybase. Optionally, you can pass a string containing the path to the Keybase executable as the first argument. func NewKeybase(path ...string) *Keybase { k := &Keybase{} @@ -62,7 +27,7 @@ func NewKeybase(path ...string) *Keybase { } k.Version = k.version() k.LoggedIn = k.loggedIn() - if k.LoggedIn == true { + if k.LoggedIn { k.Username = k.username() } return k diff --git a/types.go b/types.go index 6899926..9e17cfd 100644 --- a/types.go +++ b/types.go @@ -119,6 +119,8 @@ type msg struct { HasPairwiseMacs bool `json:"has_pairwise_macs"` ChannelMention string `json:"channel_mention"` } + +// Channel holds information about a conversation type Channel struct { Name string `json:"name"` Public bool `json:"public,omitempty"` @@ -164,3 +166,38 @@ type conversation struct { ActiveAtMs int64 `json:"active_at_ms"` MemberStatus string `json:"member_status"` } + +// Keybase holds basic information about the local Keybase executable +type Keybase struct { + Path string + Username string + LoggedIn bool + Version string +} + +// Chat holds basic information about a specific conversation +type Chat struct { + keybase *Keybase + Channel Channel +} + +type chat interface { + Send(message ...string) (ChatAPI, error) + Edit(messageID int, message ...string) (ChatAPI, error) + React(messageID int, reaction string) (ChatAPI, error) + Delete(messageID int) (ChatAPI, error) +} + +type keybase interface { + NewChat(channel Channel) Chat + Run(handler func(ChatAPI), options ...RunOptions) + ChatList() ([]conversation, error) + loggedIn() bool + username() string + version() string +} + +type status struct { + Username string `json:"Username"` + LoggedIn bool `json:"LoggedIn"` +}