Browse Source

First attempt to add LoadFlip()

main
Sam 5 years ago
parent
commit
e22b187730
  1. 18
      chat.go
  2. 46
      types.go

18
chat.go

@ -305,3 +305,21 @@ func (c Chat) Download(messageID int, filepath string) (ChatAPI, error) {
} }
return r, nil return r, nil
} }
func (c Chat) LoadFlip(messageID int, conversationID string, flipConversationID string, gameID string) (ChatAPI, error) {
m := ChatAPI{
Params: &params{},
}
m.Method = "loadflip"
m.Params.Options.Channel = c.Channel
m.Params.Options.MsgID = messageID
m.Params.Options.ConversationID = conversationID
m.Params.Options.FlipConversationID = flipConversationID
m.Params.Options.GameID = gameID
r, err := chatAPIOut(c.keybase.Path, m)
if err != nil {
return ChatAPI{}, err
}
return r, nil
}

46
types.go

@ -110,6 +110,13 @@ type text struct {
UserMentions []userMentions `json:"userMentions"` UserMentions []userMentions `json:"userMentions"`
TeamMentions []teamMentions `json:"teamMentions"` TeamMentions []teamMentions `json:"teamMentions"`
} }
type flip struct {
Text string `json:"text"`
GameID string `json:"game_id"`
FlipConvID string `json:"flip_conv_id"`
UserMentions interface{} `json:"user_mentions"`
TeamMentions interface{} `json:"team_mentions"`
}
type content struct { type content struct {
Type string `json:"type"` Type string `json:"type"`
Delete delete `json:"delete"` Delete delete `json:"delete"`
@ -118,6 +125,7 @@ type content struct {
System system `json:"system"` System system `json:"system"`
Text text `json:"text"` Text text `json:"text"`
SendPayment SendPayment `json:"send_payment"` SendPayment SendPayment `json:"send_payment"`
Flip flip `json:"flip"`
} }
type msg struct { type msg struct {
ID int `json:"id"` ID int `json:"id"`
@ -203,6 +211,10 @@ type options struct {
Filename string `json:"filename,omitempty"` Filename string `json:"filename,omitempty"`
Title string `json:"title,omitempty"` Title string `json:"title,omitempty"`
Output string `json:"output,omitempty"` Output string `json:"output,omitempty"`
ConversationID string `json:"conversation_id"`
FlipConversationID string `json:"flip_conversation_id"`
MsgID int `json:"msg_id"`
GameID string `json:"game_id"`
} }
type params struct { type params struct {
Options options `json:"options"` Options options `json:"options"`
@ -214,6 +226,37 @@ type pagination struct {
Last bool `json:"last,omitempty"` Last bool `json:"last,omitempty"`
ForceFirstPage bool `json:"forceFirstPage,omitempty"` ForceFirstPage bool `json:"forceFirstPage,omitempty"`
} }
type participants struct {
UID string `json:"uid"`
DeviceID string `json:"deviceID"`
Username string `json:"username"`
DeviceName string `json:"deviceName"`
Commitment string `json:"commitment"`
Reveal string `json:"reveal"`
}
type dupreg struct {
User string `json:"user"`
Device string `json:"device"`
}
type errorInfo struct {
Typ int `json:"typ"`
Dupreg dupreg `json:"dupreg"`
}
type resultInfo struct {
Typ int `json:"typ"`
Coin bool `json:"coin"`
}
type flipStatus struct {
GameID string `json:"gameID"`
Phase int `json:"phase"`
ProgressText string `json:"progressText"`
ResultText string `json:"resultText"`
CommitmentVisualization string `json:"commitmentVisualization"`
RevealVisualization string `json:"revealVisualization"`
Participants []participants `json:"participants"`
ResultInfo resultInfo `json:"resultInfo"`
ErrorInfo errorInfo `json:"errorInfo"`
}
type result struct { type result struct {
Messages []messages `json:"messages,omitempty"` Messages []messages `json:"messages,omitempty"`
Pagination pagination `json:"pagination"` Pagination pagination `json:"pagination"`
@ -222,6 +265,8 @@ type result struct {
Ratelimits []rateLimits `json:"ratelimits"` Ratelimits []rateLimits `json:"ratelimits"`
Conversations []conversation `json:"conversations,omitempty"` Conversations []conversation `json:"conversations,omitempty"`
Offline bool `json:"offline,omitempty"` Offline bool `json:"offline,omitempty"`
Status flipStatus `json:"status,omitempty"`
IdentifyFailures interface{} `json:"identifyFailures,omitempty"`
} }
type messages struct { type messages struct {
Msg msg `json:"msg,omitempty"` Msg msg `json:"msg,omitempty"`
@ -421,6 +466,7 @@ type chat interface {
Send(message ...string) (ChatAPI, error) Send(message ...string) (ChatAPI, error)
Upload(title string, filepath string) (ChatAPI, error) Upload(title string, filepath string) (ChatAPI, error)
Download(messageID int, filepath string) (ChatAPI, error) Download(messageID int, filepath string) (ChatAPI, error)
LoadFlip(messageID int, conversationID string, flipConversationID string, gameID string) (ChatAPI, error)
} }
type chatAPI interface { type chatAPI interface {

Loading…
Cancel
Save