Move more types into types.go and general cleanup
This commit is contained in:
37
keybase.go
37
keybase.go
@ -17,41 +17,6 @@ const (
|
|||||||
CHAT string = "chat"
|
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.
|
// 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 {
|
func NewKeybase(path ...string) *Keybase {
|
||||||
k := &Keybase{}
|
k := &Keybase{}
|
||||||
@ -62,7 +27,7 @@ func NewKeybase(path ...string) *Keybase {
|
|||||||
}
|
}
|
||||||
k.Version = k.version()
|
k.Version = k.version()
|
||||||
k.LoggedIn = k.loggedIn()
|
k.LoggedIn = k.loggedIn()
|
||||||
if k.LoggedIn == true {
|
if k.LoggedIn {
|
||||||
k.Username = k.username()
|
k.Username = k.username()
|
||||||
}
|
}
|
||||||
return k
|
return k
|
||||||
|
|||||||
37
types.go
37
types.go
@ -119,6 +119,8 @@ type msg struct {
|
|||||||
HasPairwiseMacs bool `json:"has_pairwise_macs"`
|
HasPairwiseMacs bool `json:"has_pairwise_macs"`
|
||||||
ChannelMention string `json:"channel_mention"`
|
ChannelMention string `json:"channel_mention"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Channel holds information about a conversation
|
||||||
type Channel struct {
|
type Channel struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Public bool `json:"public,omitempty"`
|
Public bool `json:"public,omitempty"`
|
||||||
@ -164,3 +166,38 @@ type conversation struct {
|
|||||||
ActiveAtMs int64 `json:"active_at_ms"`
|
ActiveAtMs int64 `json:"active_at_ms"`
|
||||||
MemberStatus string `json:"member_status"`
|
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"`
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user