diff --git a/mods/mastodon.go b/mods/mastodon.go index 1a15b25..bd8e409 100644 --- a/mods/mastodon.go +++ b/mods/mastodon.go @@ -8,6 +8,7 @@ import ( "fmt" "log" "os" + "strings" "git.fromouter.space/hamcha/tg" "github.com/mattn/go-mastodon" @@ -130,7 +131,13 @@ func mastodon_message(broker *tg.Broker, update tg.APIMessage) { return } - status, err := sendToot(*(update.Text), "") + // Strip command from beginning of text string, if it's there + text := *(update.Text) + if strings.HasPrefix(text, "/post ") || strings.HasPrefix(text, "/post@"+*botname+" ") { + text = text[strings.IndexRune(text, ' ')+1:] + } + + status, err := sendToot(text, "") if err != nil { log.Printf("[mastodon] Send toot failed: %s\n", err.Error()) broker.SendTextMessage(update.Chat, "ERRORE! @hamcha controlla la console!", &tg.MessageOptions{