2 Commits

Author SHA1 Message Date
57a2914fe3 Fix token retrieval
Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
2025-12-30 00:37:25 -03:00
cf64d9038f Sending messages to the Æther
Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
2025-12-30 00:13:59 -03:00
8 changed files with 77 additions and 18 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 GO = go
GOFLAGS = -v -ldflags "-w -X mikuru.Version=${VERSION} -X mikuru.Rev=${REVISION}" GOFLAGS = -v -buildvcs=false -buildmode=exe -ldflags "-w -X `${GO} list`.Version=${VERSION}"
REVISION = `git rev-list --all | wc -l`
VERSION = HEAD
PROGRAMS = mikuru-login \ build: mikuru-login mikuru-post
mikuru-post \
mikuru-timeline
build: mikuru-login:
${GO} build ${GOFLAGS} ./cmd/${PROGRAMS} ${GO} build ${GOFLAGS} ./cmd/$@
mikuru-post:
${GO} build ${GOFLAGS} ./cmd/$@
clean: clean:
rm -f ${PROGRAMS} rm -f mikuru-*

View File

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

View File

@@ -3,6 +3,7 @@ package main
import ( import (
"fmt" "fmt"
"os" "os"
"strings"
"syscall" "syscall"
"golang.org/x/term" "golang.org/x/term"
@@ -16,12 +17,12 @@ var (
) )
func init() { func init() {
xdg_config_home, err := os.UserConfigDir() config, err := os.UserConfigDir()
if err != nil { if err != nil {
fmt.Println("Unable to obtain user's configuration directory") fmt.Println("Unable to obtain user's configuration directory")
os.Exit(1) os.Exit(1)
} }
configPath := xdg_config_home + "/mikuru.ini" configPath := config + "/mikuru.ini"
mikuru.Parse(configPath) mikuru.Parse(configPath)
} }
@@ -59,9 +60,11 @@ func signin(cli *client.Client) {
os.Exit(1) os.Exit(1)
} }
token := strings.Trim(fmt.Sprintf(res.Token), "{}")
fmt.Println("Login successful") fmt.Println("Login successful")
fmt.Println("Place this token in your configuration file for later use") fmt.Println("Place this token in your configuration file for later use")
fmt.Println("Do not share it with anyone, it's classified information") fmt.Println("Do not share it with anyone, it's classified information")
fmt.Println("Trim surrounding braces before usage") fmt.Printf("token = %v\n", token)
fmt.Printf("token = %v\n", res)
} }

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 module git.laidback.moe/shinyoukai/mikuru
go 1.20 go 1.24.0
require ( require (
github.com/tj/go-editor v1.0.0
go.yarn.social/client v0.0.0-20250420114029-410ad71a453e go.yarn.social/client v0.0.0-20250420114029-410ad71a453e
golang.org/x/term v0.38.0 golang.org/x/term v0.38.0
gopkg.in/ini.v1 v1.67.0 gopkg.in/ini.v1 v1.67.0
) )
require ( require (
github.com/pkg/errors v0.8.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect github.com/sirupsen/logrus v1.9.3 // indirect
github.com/stretchr/testify v1.11.1 // indirect github.com/stretchr/testify v1.11.1 // indirect
go.yarn.social/types v0.0.0-20250420113154-c5a6df6d2f22 // 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/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 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 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 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= 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.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 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= 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 h1:A4wok2/cSAbvWLjHhtCrW8dvv1XlgcGRj7H15150HhA=
go.yarn.social/client v0.0.0-20250420114029-410ad71a453e/go.mod h1:+VjffjmcZMHIudGsZlnbPnavk0oSK6xf4olzExiojhg= go.yarn.social/client v0.0.0-20250420114029-410ad71a453e/go.mod h1:+VjffjmcZMHIudGsZlnbPnavk0oSK6xf4olzExiojhg=
go.yarn.social/types v0.0.0-20250420113154-c5a6df6d2f22 h1:M34aQ3AaRKE2t7JOLwoemJ65r0e8c1z4TwuHzogHvZE= go.yarn.social/types v0.0.0-20250420113154-c5a6df6d2f22 h1:M34aQ3AaRKE2t7JOLwoemJ65r0e8c1z4TwuHzogHvZE=

View File

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