add notification command
parent
84038cfd79
commit
f4bf175883
|
@ -0,0 +1,28 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/fatih/color"
|
||||||
|
"github.com/mattn/go-mastodon"
|
||||||
|
"github.com/urfave/cli"
|
||||||
|
)
|
||||||
|
|
||||||
|
func cmdNotification(c *cli.Context) error {
|
||||||
|
client := c.App.Metadata["client"].(*mastodon.Client)
|
||||||
|
notifications, err := client.GetNotifications()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, n := range notifications {
|
||||||
|
if n.Status != nil {
|
||||||
|
color.Set(color.FgHiRed)
|
||||||
|
fmt.Print(n.Account.Username)
|
||||||
|
color.Set(color.Reset)
|
||||||
|
fmt.Println(" " + n.Type)
|
||||||
|
s := n.Status
|
||||||
|
fmt.Println(textContent(s.Content))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -192,6 +192,11 @@ func run() int {
|
||||||
Usage: "show timeline",
|
Usage: "show timeline",
|
||||||
Action: cmdTimeline,
|
Action: cmdTimeline,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "notification",
|
||||||
|
Usage: "show notification",
|
||||||
|
Action: cmdNotification,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
app.Run(os.Args)
|
app.Run(os.Args)
|
||||||
return 0
|
return 0
|
||||||
|
|
Loading…
Reference in New Issue