Sending messages to the Æther
Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
This commit is contained in:
50
cmd/mikuru-post/main.go
Normal file
50
cmd/mikuru-post/main.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"git.laidback.moe/shinyoukai/mikuru"
|
||||
"go.yarn.social/client"
|
||||
"github.com/tj/go-editor"
|
||||
)
|
||||
|
||||
func init() {
|
||||
config, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
log.Fatalf("%s\n")
|
||||
}
|
||||
|
||||
configPath := config + "/mikuru.ini"
|
||||
mikuru.Parse(configPath)
|
||||
}
|
||||
|
||||
func main() {
|
||||
cli, err := client.NewClient(
|
||||
client.WithURI(mikuru.Config.Host),
|
||||
client.WithToken(mikuru.Config.Token),
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
write(cli)
|
||||
}
|
||||
|
||||
func write(cli *client.Client) {
|
||||
var post string
|
||||
|
||||
data, err := editor.Read()
|
||||
|
||||
if err != nil {
|
||||
log.Fatal("Unable to read content from editor")
|
||||
}
|
||||
|
||||
post = string(data)
|
||||
|
||||
_, err = cli.Post(post, "")
|
||||
|
||||
if err != nil {
|
||||
log.Fatal("Unable to publish tweet")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user