информация о пользователе
This commit is contained in:
@@ -45,20 +45,18 @@ type CreativeEditorFields struct {
|
||||
}
|
||||
|
||||
const inviteLinkPlaceholder = "{{invite_link}}"
|
||||
const inviteLinkPreviewURL = "https://t.me/placeholder"
|
||||
const inviteLinkPreviewURL = "https://t.me/J7_channel"
|
||||
|
||||
// GetCreativeText возвращает текст для превью креатива
|
||||
func (e *CreativeEditorFields) GetCreativeText() string {
|
||||
var result string
|
||||
|
||||
if e.Text != nil && *e.Text != "" {
|
||||
// Проверяем что текст не является "визуально пустым" HTML
|
||||
// Например: "<a class=\"tg-link\"></a>" - пустая ссылка
|
||||
text := strings.TrimSpace(*e.Text)
|
||||
|
||||
// Убираем пустые HTML-теги (простая проверка)
|
||||
if text == "<a class=\"tg-link\"></a>" || text == "" {
|
||||
log.Info().Str("text", *e.Text).Msg("GetCreativeText: text is visually empty, using default")
|
||||
// Проверяем что текст не пустой
|
||||
if text == "" {
|
||||
log.Info().Str("text", *e.Text).Msg("GetCreativeText: text is empty, using default")
|
||||
return result + `<i>💭 Я твой креатив
|
||||
|
||||
У меня пока нет текста, добавь его ниже.
|
||||
@@ -66,8 +64,14 @@ func (e *CreativeEditorFields) GetCreativeText() string {
|
||||
</i>`
|
||||
}
|
||||
|
||||
// Заменяем пустую ссылку <a class="tg-link"></a> на валидную preview-ссылку
|
||||
text = strings.ReplaceAll(text, `<a class="tg-link"></a>`, `<a href="`+inviteLinkPreviewURL+`">👉 Подписаться</a>`)
|
||||
|
||||
// Также заменяем плейсхолдер {{invite_link}} на preview URL (как в кнопках)
|
||||
text = strings.ReplaceAll(text, inviteLinkPlaceholder, inviteLinkPreviewURL)
|
||||
|
||||
log.Info().Str("text", *e.Text).Msg("GetCreativeText: returning creative text")
|
||||
return result + *e.Text
|
||||
return result + text
|
||||
}
|
||||
log.Info().Bool("text_is_nil", e.Text == nil).Msg("GetCreativeText: returning default text")
|
||||
return result + `<i>💭 Я твой креатив
|
||||
@@ -156,6 +160,9 @@ func (e *CreativeEditorFields) SendCreativePreview(b *bot.Bot) {
|
||||
res, err := b.SendMessage(creativeText, b.ChatID, &echotron.MessageOptions{
|
||||
ReplyMarkup: keyboard,
|
||||
ParseMode: echotron.HTML,
|
||||
LinkPreviewOptions: echotron.LinkPreviewOptions{
|
||||
IsDisabled: true,
|
||||
},
|
||||
})
|
||||
if err == nil && res.Result != nil {
|
||||
msgID = res.Result.ID
|
||||
@@ -169,6 +176,9 @@ func (e *CreativeEditorFields) SendCreativePreview(b *bot.Bot) {
|
||||
res, err := b.SendMessage(creativeText, b.ChatID, &echotron.MessageOptions{
|
||||
ReplyMarkup: keyboard,
|
||||
ParseMode: echotron.HTML,
|
||||
LinkPreviewOptions: echotron.LinkPreviewOptions{
|
||||
IsDisabled: true,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Failed to send creative preview")
|
||||
@@ -258,6 +268,9 @@ func (e *CreativeEditorFields) UpdateCreativePreview(b *bot.Bot) {
|
||||
&echotron.MessageTextOptions{
|
||||
ParseMode: echotron.HTML,
|
||||
ReplyMarkup: keyboard,
|
||||
LinkPreviewOptions: echotron.LinkPreviewOptions{
|
||||
IsDisabled: true,
|
||||
},
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user