Strip /post from text string
This commit is contained in:
parent
876338370e
commit
b7d6ea332a
1 changed files with 8 additions and 1 deletions
|
@ -8,6 +8,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"git.fromouter.space/hamcha/tg"
|
"git.fromouter.space/hamcha/tg"
|
||||||
"github.com/mattn/go-mastodon"
|
"github.com/mattn/go-mastodon"
|
||||||
|
@ -130,7 +131,13 @@ func mastodon_message(broker *tg.Broker, update tg.APIMessage) {
|
||||||
return
|
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 {
|
if err != nil {
|
||||||
log.Printf("[mastodon] Send toot failed: %s\n", err.Error())
|
log.Printf("[mastodon] Send toot failed: %s\n", err.Error())
|
||||||
broker.SendTextMessage(update.Chat, "<b>ERRORE!</b> @hamcha controlla la console!", &tg.MessageOptions{
|
broker.SendTextMessage(update.Chat, "<b>ERRORE!</b> @hamcha controlla la console!", &tg.MessageOptions{
|
||||||
|
|
Reference in a new issue