First attempt to add LoadFlip()

This commit is contained in:
Sam
2019-09-10 17:49:51 -04:00
parent d99546ae79
commit e22b187730
2 changed files with 78 additions and 14 deletions

18
chat.go
View File

@ -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
}

View File

@ -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"`
@ -196,13 +204,17 @@ type message struct {
Body string `json:"body"` Body string `json:"body"`
} }
type options struct { type options struct {
Channel Channel `json:"channel"` Channel Channel `json:"channel"`
MessageID int `json:"message_id"` MessageID int `json:"message_id"`
Message message `json:"message"` Message message `json:"message"`
Pagination pagination `json:"pagination"` Pagination pagination `json:"pagination"`
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,14 +226,47 @@ 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"`
Message string `json:"message"` Message string `json:"message"`
ID int `json:"id"` ID int `json:"id"`
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 {