diff --git a/bridge/telegram/handlers.go b/bridge/telegram/handlers.go index c5ed8c46..a27a6732 100644 --- a/bridge/telegram/handlers.go +++ b/bridge/telegram/handlers.go @@ -201,7 +201,8 @@ func (b *Btelegram) handleRecv(updates <-chan tgbotapi.Update) { b.handleEntities(&rmsg, message) if rmsg.Text != "" || len(rmsg.Extra) > 0 { - rmsg.Text = helper.RemoveEmptyNewLines(rmsg.Text) + // Comment the next line out due to avoid removing empty lines in Telegram + // rmsg.Text = helper.RemoveEmptyNewLines(rmsg.Text) // channels don't have (always?) user information. see #410 if message.From != nil { rmsg.Avatar = helper.GetAvatar(b.avatarMap, strconv.FormatInt(message.From.ID, 10), b.General) @@ -509,5 +510,21 @@ func (b *Btelegram) handleEntities(rmsg *config.Message, message *tgbotapi.Messa rmsg.Text = rmsg.Text[:offset] + "```\n" + rmsg.Text[offset:offset+e.Length] + "\n```" + rmsg.Text[offset+e.Length:] indexMovedBy += 8 } + + if e.Type == "bold" { + offset := e.Offset + indexMovedBy + rmsg.Text = rmsg.Text[:offset] + "*" + rmsg.Text[offset:offset+e.Length] + "*" + rmsg.Text[offset+e.Length:] + indexMovedBy += 2 + } + if e.Type == "italic" { + offset := e.Offset + indexMovedBy + rmsg.Text = rmsg.Text[:offset] + "_" + rmsg.Text[offset:offset+e.Length] + "_" + rmsg.Text[offset+e.Length:] + indexMovedBy += 2 + } + if e.Type == "strike" { + offset := e.Offset + indexMovedBy + rmsg.Text = rmsg.Text[:offset] + "~" + rmsg.Text[offset:offset+e.Length] + "~" + rmsg.Text[offset+e.Length:] + indexMovedBy += 2 + } } }