export ID for stream. add -i to reply

pull/28/head
Yasuhiro Matsumoto 2017-04-19 15:17:26 +09:00
parent 998ab3d74a
commit e47dd5a618
3 changed files with 9 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import (
) )
type SimpleJSON struct { type SimpleJSON struct {
ID int64 `json:"id"`
Username string `json:"username"` Username string `json:"username"`
Avatar string `json:"avatar"` Avatar string `json:"avatar"`
Content string `json:"content"` Content string `json:"content"`
@ -41,6 +42,7 @@ func cmdStream(c *cli.Context) error {
} else if asSimpleJSON { } else if asSimpleJSON {
if t, ok := e.(*mastodon.UpdateEvent); ok { if t, ok := e.(*mastodon.UpdateEvent); ok {
json.NewEncoder(c.App.Writer).Encode(&SimpleJSON{ json.NewEncoder(c.App.Writer).Encode(&SimpleJSON{
ID: t.Status.ID,
Username: t.Status.Account.Username, Username: t.Status.Account.Username,
Avatar: t.Status.Account.AvatarStatic, Avatar: t.Status.Account.AvatarStatic,
Content: textContent(t.Status.Content), Content: textContent(t.Status.Content),

View File

@ -26,7 +26,8 @@ func cmdToot(c *cli.Context) error {
} }
client := c.App.Metadata["client"].(*mastodon.Client) client := c.App.Metadata["client"].(*mastodon.Client)
_, err := client.PostStatus(context.Background(), &mastodon.Toot{ _, err := client.PostStatus(context.Background(), &mastodon.Toot{
Status: toot, Status: toot,
InReplyToID: c.Int64("i"),
}) })
return err return err
} }

View File

@ -174,6 +174,11 @@ func makeApp() *cli.App {
Usage: "post utf-8 string from a file(\"-\" means STDIN)", Usage: "post utf-8 string from a file(\"-\" means STDIN)",
Value: "", Value: "",
}, },
cli.IntFlag{
Name: "i",
Usage: "in-reply-to",
Value: 0,
},
}, },
Action: cmdToot, Action: cmdToot,
}, },