Skip to content

Instantly share code, notes, and snippets.

@uraimo
Created November 7, 2022 10:51
Show Gist options
  • Save uraimo/174ffaa816d894b5ab9fda89d085139b to your computer and use it in GitHub Desktop.
Save uraimo/174ffaa816d894b5ab9fda89d085139b to your computer and use it in GitHub Desktop.

Revisions

  1. uraimo created this gist Nov 7, 2022.
    33 changes: 33 additions & 0 deletions masto_this.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    package main

    import (
    "os"
    "strings"
    "context"
    "log"
    "github.com/mattn/go-mastodon" //Thanks Mattn!
    )

    func main() {
    args := os.Args[1:]
    toot := strings.Join(args," ")

    c := mastodon.NewClient(&mastodon.Config{
    Server: "https://mastodon.social",
    ClientID: "133t133t133t133t133t133t133t133t133t133t133t",
    ClientSecret: "133t133t133t133t133t133t133t133t-133t133t",
    })

    err := c.Authenticate(context.Background(), "youremail", "yourpwd")
    if err != nil {
    log.Fatal(err)
    }

    _, err = c.PostStatus(context.Background(), &mastodon.Toot{
    Status: toot,
    })

    if err != nil {
    log.Fatal(err)
    }
    }