From bda25e2c203d18c87d7a0114b698792b3fa8d0ad Mon Sep 17 00:00:00 2001 From: Daniele Tricoli Date: Tue, 1 Mar 2022 01:41:32 +0100 Subject: [PATCH] Just use AccessToken to connect to Mastodon after correctly getting it --- cmd/run.go | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/cmd/run.go b/cmd/run.go index e1a1e7a..946edec 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -1,7 +1,3 @@ -/* -Copyright © 2022 NAME HERE - -*/ package cmd import ( @@ -19,8 +15,6 @@ const ( DEBUG = "DEBUG" TELEGRAM_BOT_TOKEN = "TELEGRAM_BOT_TOKEN" MASTODON_SERVER_ADDRESS = "MASTODON_SERVER_ADDRESS" - MASTODON_CLIENT_ID = "MASTODON_CLIENT_ID" - MASTODON_SECRET = "MASTODON_SECRET" MASTODON_ACCESS_TOKEN = "MASTODON_ACCESS_TOKEN" ) @@ -35,17 +29,11 @@ the specified Mastodon account.`, Run: func(cmd *cobra.Command, args []string) { mastodon_instance := os.Getenv(MASTODON_SERVER_ADDRESS) c := mastodon.NewClient(&mastodon.Config{ - Server: mastodon_instance, - ClientID: os.Getenv(MASTODON_CLIENT_ID), - ClientSecret: os.Getenv(MASTODON_SECRET), + Server: mastodon_instance, + AccessToken: os.Getenv(MASTODON_ACCESS_TOKEN), }) log.Println("Crating a new client for mastondon istance:", mastodon_instance) - err := c.AuthenticateToken(context.Background(), os.Getenv(MASTODON_ACCESS_TOKEN), os.Getenv(MASTODON_REDIRECT_URI)) - if err != nil { - log.Fatal(err) - } - bot, err := tgbotapi.NewBotAPI(os.Getenv(TELEGRAM_BOT_TOKEN)) if err != nil { log.Panic(err) @@ -64,7 +52,8 @@ the specified Mastodon account.`, log.Println(update.Message) status, err := c.PostStatus(context.Background(), &mastodon.Toot{ - Status: update.Message.Text, + Status: update.Message.Text, + // TODO: make users able to set visibility Visibility: "unlisted", })