From 5a8fa8ebd73090e7b4488639b051cbf8b476d617 Mon Sep 17 00:00:00 2001 From: Alexander Kiryukhin Date: Wed, 17 Apr 2019 15:28:21 +0300 Subject: Refactoring --- plugins/tg.go | 3 ++- plugins/tt.go | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/tg.go b/plugins/tg.go index ccd3a9b..416d4db 100644 --- a/plugins/tg.go +++ b/plugins/tg.go @@ -8,6 +8,7 @@ import ( "log" "net/http" "os" + "strings" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api" "github.com/neonxp/tamtam" @@ -80,7 +81,7 @@ func (t *Telegram) Run(ctx context.Context) error { for _, a := range msg.Images { att = append(att, tamtam.Image{Url: a}) } - text := fmt.Sprintf("*%s*:\n%s", msg.From, msg.Text) + text := fmt.Sprintf("*%s*:\n%s", strings.Trim(msg.From, " "), msg.Text) if len(msg.Text) > 0 { res, err := t.API.Send(tgbotapi.MessageConfig{ BaseChat: tgbotapi.BaseChat{ diff --git a/plugins/tt.go b/plugins/tt.go index 89fa77c..9891e66 100644 --- a/plugins/tt.go +++ b/plugins/tt.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "log" + "strings" "github.com/neonxp/tamtam" @@ -68,9 +69,9 @@ func (t *TamTam) Run(ctx context.Context) error { } case msg := <-t.Updates: - text := fmt.Sprintf("*%s*:\n%s", msg.From, msg.Text) + text := fmt.Sprintf("*%s*:\n%s", strings.Trim(msg.From, " "), msg.Text) if msg.Sticker != "" { - text = fmt.Sprintf("*%s*: [%s]", msg.From, msg.Sticker) + text = fmt.Sprintf("*%s*: [%s]", strings.Trim(msg.From, " "), msg.Sticker) } attachments := make([]interface{}, 0, len(msg.Images)) if len(msg.Images) > 0 { -- cgit v1.2.3