diff options
| author | Christine Dodrill <me@christine.website> | 2019-01-26 09:55:54 -0800 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2019-01-26 09:55:54 -0800 |
| commit | e722cdd06a891caee44238a1161d04b576cfc31b (patch) | |
| tree | 0911b873bd6a83f3dd015842f5183fe7aa1294f8 /mastodon | |
| parent | a0b5fc1c39e9aba464a9178da150cf0da863a47f (diff) | |
| download | x-e722cdd06a891caee44238a1161d04b576cfc31b.tar.xz x-e722cdd06a891caee44238a1161d04b576cfc31b.zip | |
mastodon/tptrans: use relex
Diffstat (limited to 'mastodon')
| -rw-r--r-- | mastodon/tptrans/main.go | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/mastodon/tptrans/main.go b/mastodon/tptrans/main.go index 3daf76d..c24fa14 100644 --- a/mastodon/tptrans/main.go +++ b/mastodon/tptrans/main.go @@ -4,13 +4,11 @@ import ( "context" "flag" "fmt" - "io/ioutil" - "net/http" madon "github.com/McKael/madon/v2" "github.com/Xe/x/internal" + "github.com/Xe/x/tokipona" _ "github.com/Xe/x/tokipona" - "github.com/Xe/x/web/tokipana" "github.com/jaytaylor/html2text" _ "github.com/joho/godotenv/autoload" "within.website/ln" @@ -82,27 +80,11 @@ func main() { continue } - req := tokipana.Translate(text) - resp, err := http.DefaultClient.Do(req) - if err != nil { - ln.Error(ctx, err) - continue - } - err = tokipana.Validate(resp) - if err != nil { - ln.Error(ctx, err) - continue - } - data, err := ioutil.ReadAll(resp.Body) - resp.Body.Close() - if err != nil { - ln.Error(ctx, err) - continue - } + data := tokipona.Relex(text) st, err := c.PostStatus( madon.PostStatusParams{ - Text: fmt.Sprintf(translationTemplate, string(data)), + Text: fmt.Sprintf(translationTemplate, data), InReplyTo: s.ID, Visibility: "public", }, @@ -121,4 +103,4 @@ func main() { redo: } -const translationTemplate = `Translated into English: %s` +const translationTemplate = `Badly translated into English: %s` |
