Sending messages to the Æther

Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
This commit is contained in:
2025-12-30 00:13:59 -03:00
parent 2ab278fc5d
commit cf64d9038f
7 changed files with 70 additions and 14 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/mikuru-*

View File

@@ -1,13 +1,13 @@
VERSION = `git describe --tags` || echo MIRAI
GO = go
GOFLAGS = -v -ldflags "-w -X mikuru.Version=${VERSION} -X mikuru.Rev=${REVISION}"
REVISION = `git rev-list --all | wc -l`
VERSION = HEAD
GOFLAGS = -v -buildvcs=false -buildmode=exe -ldflags "-w -X `${GO} list`.Version=${VERSION}"
PROGRAMS = mikuru-login \
mikuru-post \
mikuru-timeline
build: mikuru-login mikuru-post
build:
${GO} build ${GOFLAGS} ./cmd/${PROGRAMS}
mikuru-login:
${GO} build ${GOFLAGS} ./cmd/$@
mikuru-post:
${GO} build ${GOFLAGS} ./cmd/$@
clean:
rm -f ${PROGRAMS}
rm -f mikuru-*

View File

@@ -3,14 +3,14 @@
## Current status
* [X] Login
* [ ] Posting
* [X] Posting
* [ ] Timeline
## License
[ISC](COPYING)
## Requirements
* [Go](https://go.dev) (>=1.20)
* [Go](https://go.dev) (>=1.24)
## Where did the name come from?
Huh? I couldn't possibly tell you about that!

50
cmd/mikuru-post/main.go Normal file
View 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")
}
}

4
go.mod
View File

@@ -1,14 +1,16 @@
module git.laidback.moe/shinyoukai/mikuru
go 1.20
go 1.24.0
require (
github.com/tj/go-editor v1.0.0
go.yarn.social/client v0.0.0-20250420114029-410ad71a453e
golang.org/x/term v0.38.0
gopkg.in/ini.v1 v1.67.0
)
require (
github.com/pkg/errors v0.8.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/stretchr/testify v1.11.1 // indirect
go.yarn.social/types v0.0.0-20250420113154-c5a6df6d2f22 // indirect

4
go.sum
View File

@@ -5,6 +5,8 @@ github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
@@ -15,6 +17,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tj/go-editor v1.0.0 h1:VduwRZWk5gxHbzRkS4buB9BIFzAf6Jc+vd2bLZpHzSw=
github.com/tj/go-editor v1.0.0/go.mod h1:Jj9Ze2Rn2yj5DmMppydZqr9LbkIcCWrehzZ+7udOT+w=
go.yarn.social/client v0.0.0-20250420114029-410ad71a453e h1:A4wok2/cSAbvWLjHhtCrW8dvv1XlgcGRj7H15150HhA=
go.yarn.social/client v0.0.0-20250420114029-410ad71a453e/go.mod h1:+VjffjmcZMHIudGsZlnbPnavk0oSK6xf4olzExiojhg=
go.yarn.social/types v0.0.0-20250420113154-c5a6df6d2f22 h1:M34aQ3AaRKE2t7JOLwoemJ65r0e8c1z4TwuHzogHvZE=

View File

@@ -5,10 +5,9 @@ import (
)
var (
Revision = "0"
Version = "0"
)
func PrintVersion() string {
return fmt.Sprintf("%s (%s)", Version, Revision)
return fmt.Sprintf("%s", Version)
}