|
|
@ -5,10 +5,9 @@ import ( |
|
|
|
"os/exec" |
|
|
|
"os/exec" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---- Struct for sending to API
|
|
|
|
// ---- Struct for sending to API
|
|
|
|
type chatOut struct { |
|
|
|
type chatOut struct { |
|
|
|
Method string `json:"method"` |
|
|
|
Method string `json:"method"` |
|
|
|
Params chatOutParams `json:"params"` |
|
|
|
Params chatOutParams `json:"params"` |
|
|
|
} |
|
|
|
} |
|
|
|
type chatOutChannel struct { |
|
|
|
type chatOutChannel struct { |
|
|
@ -26,6 +25,7 @@ type chatOutOptions struct { |
|
|
|
type chatOutParams struct { |
|
|
|
type chatOutParams struct { |
|
|
|
Options chatOutOptions `json:"options"` |
|
|
|
Options chatOutOptions `json:"options"` |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ----
|
|
|
|
// ----
|
|
|
|
|
|
|
|
|
|
|
|
// ---- Struct for data received after sending to API
|
|
|
|
// ---- Struct for data received after sending to API
|
|
|
@ -33,16 +33,34 @@ type chatOutResult struct { |
|
|
|
Result chatOutResultResult `json:"result"` |
|
|
|
Result chatOutResultResult `json:"result"` |
|
|
|
} |
|
|
|
} |
|
|
|
type chatOutResultRatelimits struct { |
|
|
|
type chatOutResultRatelimits struct { |
|
|
|
Tank string `json:"tank"` |
|
|
|
Tank string `json:"tank,omitempty"` |
|
|
|
Capacity int `json:"capacity"` |
|
|
|
Capacity int `json:"capacity,omitempty"` |
|
|
|
Reset int `json:"reset"` |
|
|
|
Reset int `json:"reset,omitempty"` |
|
|
|
Gas int `json:"gas"` |
|
|
|
Gas int `json:"gas,omitempty"` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
type chatOutResultChannel struct { |
|
|
|
|
|
|
|
Name string `json:"name"` |
|
|
|
|
|
|
|
Public bool `json:"public"` |
|
|
|
|
|
|
|
MembersType string `json:"members_type"` |
|
|
|
|
|
|
|
TopicType string `json:"topic_type,omitempty"` |
|
|
|
|
|
|
|
TopicName string `json:"topic_name,omitempty"` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
type chatOutResultConversations struct { |
|
|
|
|
|
|
|
ID string `json:"id"` |
|
|
|
|
|
|
|
Channel chatOutResultChannel `json:"channel"` |
|
|
|
|
|
|
|
Unread bool `json:"unread"` |
|
|
|
|
|
|
|
ActiveAt int `json:"active_at"` |
|
|
|
|
|
|
|
ActiveAtMs int64 `json:"active_at_ms"` |
|
|
|
|
|
|
|
MemberStatus string `json:"member_status"` |
|
|
|
} |
|
|
|
} |
|
|
|
type chatOutResultResult struct { |
|
|
|
type chatOutResultResult struct { |
|
|
|
Message string `json:"message"` |
|
|
|
Message string `json:"message,omitempty"` |
|
|
|
ID int `json:"id"` |
|
|
|
ID int `json:"id,omitempty"` |
|
|
|
Ratelimits []chatOutResultRatelimits `json:"ratelimits"` |
|
|
|
Ratelimits []chatOutResultRatelimits `json:"ratelimits,omitempty"` |
|
|
|
|
|
|
|
Conversations []chatOutResultConversations `json:"conversations,omitempty"` |
|
|
|
|
|
|
|
Offline bool `json:"offline,omitempty"` |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ----
|
|
|
|
// ----
|
|
|
|
|
|
|
|
|
|
|
|
// chatAPIOut() sends JSON requests to the chat API and returns its response.
|
|
|
|
// chatAPIOut() sends JSON requests to the chat API and returns its response.
|
|
|
@ -82,3 +100,12 @@ func (k Keybase) ChatSendTeam(team, channel, message string) (chatOutResult, err |
|
|
|
|
|
|
|
|
|
|
|
return chatAPIOut(k.path, m) |
|
|
|
return chatAPIOut(k.path, m) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ChatList() returns a list of all conversations.
|
|
|
|
|
|
|
|
func (k Keybase) ChatList() ([]chatOutResultConversations, error) { |
|
|
|
|
|
|
|
m := chatOut{} |
|
|
|
|
|
|
|
m.Method = "list" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
r, err := chatAPIOut(k.path, m) |
|
|
|
|
|
|
|
return r.Result.Conversations, err |
|
|
|
|
|
|
|
} |
|
|
|