Changed chatOutResultResult to ChatOut for ease of use
This commit is contained in:
30
chatOut.go
30
chatOut.go
@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ---- Struct for sending to API
|
// ---- Struct for sending to API
|
||||||
type chatOut struct {
|
type chatOut struct { // not exported
|
||||||
Method string `json:"method"`
|
Method string `json:"method"`
|
||||||
Params chatOutParams `json:"params"`
|
Params chatOutParams `json:"params"`
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ type chatOutParams struct {
|
|||||||
|
|
||||||
// ---- Struct for data received after sending to API
|
// ---- Struct for data received after sending to API
|
||||||
type chatOutResult struct {
|
type chatOutResult struct {
|
||||||
Result chatOutResultResult `json:"result"`
|
Result ChatOut `json:"result"`
|
||||||
}
|
}
|
||||||
type chatOutResultRatelimits struct {
|
type chatOutResultRatelimits struct {
|
||||||
Tank string `json:"tank,omitempty"`
|
Tank string `json:"tank,omitempty"`
|
||||||
@ -55,7 +55,7 @@ type chatOutResultConversations struct {
|
|||||||
ActiveAtMs int64 `json:"active_at_ms"`
|
ActiveAtMs int64 `json:"active_at_ms"`
|
||||||
MemberStatus string `json:"member_status"`
|
MemberStatus string `json:"member_status"`
|
||||||
}
|
}
|
||||||
type chatOutResultResult struct {
|
type ChatOut struct { // exported
|
||||||
Message string `json:"message,omitempty"`
|
Message string `json:"message,omitempty"`
|
||||||
ID int `json:"id,omitempty"`
|
ID int `json:"id,omitempty"`
|
||||||
Ratelimits []chatOutResultRatelimits `json:"ratelimits,omitempty"`
|
Ratelimits []chatOutResultRatelimits `json:"ratelimits,omitempty"`
|
||||||
@ -82,7 +82,7 @@ func chatAPIOut(keybasePath string, c chatOut) (chatOutResult, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ChatSendText() sends a chat message to a user.
|
// ChatSendText() sends a chat message to a user.
|
||||||
func (k Keybase) ChatSendText(user string, message ...string) (chatOutResultResult, error) {
|
func (k Keybase) ChatSendText(user string, message ...string) (ChatOut, error) {
|
||||||
m := chatOut{}
|
m := chatOut{}
|
||||||
m.Method = "send"
|
m.Method = "send"
|
||||||
m.Params.Options.Channel.Name = user
|
m.Params.Options.Channel.Name = user
|
||||||
@ -90,13 +90,13 @@ func (k Keybase) ChatSendText(user string, message ...string) (chatOutResultResu
|
|||||||
|
|
||||||
r, err := chatAPIOut(k.path, m)
|
r, err := chatAPIOut(k.path, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return chatOutResultResult{}, err
|
return ChatOut{}, err
|
||||||
}
|
}
|
||||||
return r.Result, nil
|
return r.Result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChatSendTextTeam() sends a chat message to a team.
|
// ChatSendTextTeam() sends a chat message to a team.
|
||||||
func (k Keybase) ChatSendTextTeam(team, channel string, message ...string) (chatOutResultResult, error) {
|
func (k Keybase) ChatSendTextTeam(team, channel string, message ...string) (ChatOut, error) {
|
||||||
m := chatOut{}
|
m := chatOut{}
|
||||||
m.Method = "send"
|
m.Method = "send"
|
||||||
m.Params.Options.Channel.Name = team
|
m.Params.Options.Channel.Name = team
|
||||||
@ -106,13 +106,13 @@ func (k Keybase) ChatSendTextTeam(team, channel string, message ...string) (chat
|
|||||||
|
|
||||||
r, err := chatAPIOut(k.path, m)
|
r, err := chatAPIOut(k.path, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return chatOutResultResult{}, err
|
return ChatOut{}, err
|
||||||
}
|
}
|
||||||
return r.Result, nil
|
return r.Result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChatSendReaction() sends a reaction to a user's message.
|
// ChatSendReaction() sends a reaction to a user's message.
|
||||||
func (k Keybase) ChatSendReaction(user, reaction string, messageId int) (chatOutResultResult, error) {
|
func (k Keybase) ChatSendReaction(user, reaction string, messageId int) (ChatOut, error) {
|
||||||
m := chatOut{}
|
m := chatOut{}
|
||||||
m.Method = "reaction"
|
m.Method = "reaction"
|
||||||
m.Params.Options.Channel.Name = user
|
m.Params.Options.Channel.Name = user
|
||||||
@ -121,13 +121,13 @@ func (k Keybase) ChatSendReaction(user, reaction string, messageId int) (chatOut
|
|||||||
|
|
||||||
r, err := chatAPIOut(k.path, m)
|
r, err := chatAPIOut(k.path, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return chatOutResultResult{}, err
|
return ChatOut{}, err
|
||||||
}
|
}
|
||||||
return r.Result, nil
|
return r.Result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChatSendReactionTeam() sends a reaction to a message on a team.
|
// ChatSendReactionTeam() sends a reaction to a message on a team.
|
||||||
func (k Keybase) ChatSendReactionTeam(team, channel, reaction string, messageId int) (chatOutResultResult, error) {
|
func (k Keybase) ChatSendReactionTeam(team, channel, reaction string, messageId int) (ChatOut, error) {
|
||||||
m := chatOut{}
|
m := chatOut{}
|
||||||
m.Method = "reaction"
|
m.Method = "reaction"
|
||||||
m.Params.Options.Channel.Name = team
|
m.Params.Options.Channel.Name = team
|
||||||
@ -138,13 +138,13 @@ func (k Keybase) ChatSendReactionTeam(team, channel, reaction string, messageId
|
|||||||
|
|
||||||
r, err := chatAPIOut(k.path, m)
|
r, err := chatAPIOut(k.path, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return chatOutResultResult{}, err
|
return ChatOut{}, err
|
||||||
}
|
}
|
||||||
return r.Result, nil
|
return r.Result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChatDeleteMessage() deletes a message from a one-on-one conversation.
|
// ChatDeleteMessage() deletes a message from a one-on-one conversation.
|
||||||
func (k Keybase) ChatDeleteMessage(user string, messageId int) (chatOutResultResult, error) {
|
func (k Keybase) ChatDeleteMessage(user string, messageId int) (ChatOut, error) {
|
||||||
m := chatOut{}
|
m := chatOut{}
|
||||||
m.Method = "delete"
|
m.Method = "delete"
|
||||||
m.Params.Options.Channel.Name = user
|
m.Params.Options.Channel.Name = user
|
||||||
@ -152,13 +152,13 @@ func (k Keybase) ChatDeleteMessage(user string, messageId int) (chatOutResultRes
|
|||||||
|
|
||||||
r, err := chatAPIOut(k.path, m)
|
r, err := chatAPIOut(k.path, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return chatOutResultResult{}, err
|
return ChatOut{}, err
|
||||||
}
|
}
|
||||||
return r.Result, nil
|
return r.Result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChatDeleteMessageTeam() deletes a message from a team conversation.
|
// ChatDeleteMessageTeam() deletes a message from a team conversation.
|
||||||
func (k Keybase) ChatDeleteMessageTeam(team, channel string, messageId int) (chatOutResultResult, error) {
|
func (k Keybase) ChatDeleteMessageTeam(team, channel string, messageId int) (ChatOut, error) {
|
||||||
m := chatOut{}
|
m := chatOut{}
|
||||||
m.Method = "delete"
|
m.Method = "delete"
|
||||||
m.Params.Options.Channel.Name = team
|
m.Params.Options.Channel.Name = team
|
||||||
@ -168,7 +168,7 @@ func (k Keybase) ChatDeleteMessageTeam(team, channel string, messageId int) (cha
|
|||||||
|
|
||||||
r, err := chatAPIOut(k.path, m)
|
r, err := chatAPIOut(k.path, m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return chatOutResultResult{}, err
|
return ChatOut{}, err
|
||||||
}
|
}
|
||||||
return r.Result, nil
|
return r.Result, nil
|
||||||
}
|
}
|
||||||
|
|||||||
12
keybase.go
12
keybase.go
@ -10,12 +10,12 @@ type Keybase struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type keybase interface {
|
type keybase interface {
|
||||||
ChatSendText(user string, message ...string) (chatOutResultResult, error)
|
ChatSendText(user string, message ...string) (ChatOut, error)
|
||||||
ChatSendTextTeam(team, channel, message string) (chatOutResultResult, error)
|
ChatSendTextTeam(team, channel, message string) (ChatOut, error)
|
||||||
ChatSendReaction(user, reaction string, messageId int) (chatOutResultResult, error)
|
ChatSendReaction(user, reaction string, messageId int) (ChatOut, error)
|
||||||
ChatSendReactionTeam(team, channel, reaction string, messageId int) (chatOutResultResult, error)
|
ChatSendReactionTeam(team, channel, reaction string, messageId int) (ChatOut, error)
|
||||||
ChatDeleteMessage(user string, messageId int) (chatOutResultResult, error)
|
ChatDeleteMessage(user string, messageId int) (ChatOut, error)
|
||||||
ChatDeleteMessageTeam(team, channel string, messageId int) (chatOutResultResult, error)
|
ChatDeleteMessageTeam(team, channel string, messageId int) (ChatOut, error)
|
||||||
ChatList() ([]chatOutResultConversations, error)
|
ChatList() ([]chatOutResultConversations, error)
|
||||||
LoggedIn() bool
|
LoggedIn() bool
|
||||||
Username() string
|
Username() string
|
||||||
|
|||||||
Reference in New Issue
Block a user