diff --git a/discordBot/handler.go b/discordBot/handler.go index 1fa98ed..f3c2e7f 100644 --- a/discordBot/handler.go +++ b/discordBot/handler.go @@ -65,7 +65,7 @@ func (d *DiscordBot) Start(fromTelegram <-chan dto.TelegramDTO) chan dto.Discord files = append(files, file) } - m := discord.MessageCreate{Content: fmt.Sprintf("[%s]\n%s", msg.AuthorName, msg.Content)} + m := discord.MessageCreate{Content: fmt.Sprintf("**[%s]**\n%s", msg.AuthorName, msg.Content)} if len(files) > 0 { m.Files = append(m.Files, files...) diff --git a/tgBot/handler.go b/tgBot/handler.go index 40c52c0..e086439 100644 --- a/tgBot/handler.go +++ b/tgBot/handler.go @@ -57,19 +57,21 @@ func (b *TgBot) Start(fromDiscord chan dto.DiscordDTO) chan dto.TelegramDTO { go func() { for msg := range fromDiscord { log.WithField("content", msg).Debug("TG | Message from Discord") - m := fmt.Sprintf("[%s]\n%s", msg.AuthorName, msg.Content) + + m := fmt.Sprintf("*\\[ %s \\]*\n%s", msg.AuthorName, msg.Content) b.bot.SendMessage(b.ctx, &bot.SendMessageParams{ - ChatID: b.chatID, - Text: m, + ChatID: b.chatID, + Text: m, + ParseMode: "", }) if msg.Images != nil { var mediaGroup []models.InputMedia for _, img := range *msg.Images { photo := &models.InputMediaPhoto{ - Media: fmt.Sprintf("attach://%s", img.Filename), - Caption: "test caption", + Media: fmt.Sprintf("attach://%s", img.Filename), + //Caption: "test caption", MediaAttachment: bytes.NewReader(img.Data), } mediaGroup = append(mediaGroup, photo) @@ -146,7 +148,7 @@ func (b *TgBot) proccessSimple(update *models.Update, msgChan chan<- dto.Telegra } msg := dto.TelegramDTO{ - AuthorName: update.Message.From.Username, + AuthorName: b.getName(update), Content: content, Images: &images, } @@ -185,7 +187,7 @@ func (b *TgBot) processMediaGroup(update *models.Update, mediaGroupID string, ms delete(b.mediaGroupCache, mediaGroupID) msg := dto.TelegramDTO{ - AuthorName: update.Message.From.Username, + AuthorName: b.getName(update), Content: content, Images: &images, } @@ -193,3 +195,16 @@ func (b *TgBot) processMediaGroup(update *models.Update, mediaGroupID string, ms msgChan <- msg }() } + +func (b *TgBot) getName(update *models.Update) string { + switch { + case update.Message.From.Username != "": + return update.Message.From.Username + case update.Message.From.FirstName != "": + return update.Message.From.FirstName + case update.Message.From.LastName != "": + return update.Message.From.LastName + default: + return "No name" + } +}