время в топе и тэги креативов

This commit is contained in:
Artem Tsyrulnikov
2026-01-28 12:34:00 +03:00
parent 0b25566ffb
commit 484e52c077
26 changed files with 326 additions and 36 deletions

View File

@@ -378,6 +378,7 @@ type Creative struct {
ProjectChannelTitle string `json:"project_channel_title"`
CreatedAt string `json:"created_at"`
Status string `json:"status"`
Tag string `json:"tag"`
PlacementsCount int `json:"placements_count"`
}
@@ -463,6 +464,7 @@ type CreateCreativeInput struct {
Text string `json:"text"`
MediaItems []CreativeMediaInput `json:"media_items,omitempty"`
Buttons []CreativeButton `json:"buttons,omitempty"`
Tag *string `json:"tag,omitempty"`
}
func (c *Client) CreateCreative(
@@ -496,6 +498,7 @@ type UpdateCreativeInput struct {
MediaItems *[]CreativeMediaInput `json:"media_items,omitempty"`
Buttons *[]CreativeButton `json:"buttons,omitempty"`
Status *string `json:"status,omitempty"`
Tag *string `json:"tag,omitempty"`
}
func (c *Client) UpdateCreative(

View File

@@ -188,6 +188,18 @@ func (s *AddCreativeEdit) HandleCallback(b *bot.Bot, u *echotron.Update) {
s.ctx.MediaChanged = true
s.ctx.UpdateCreativePreview(b)
s.Enter(b, bot.EditMessage)
case data == "edit_tag":
s.ctx.ShowTagPanel(b)
case data == "tag_testing":
tag := "testing"
s.ctx.Tag = &tag
s.Enter(b, bot.EditMessage)
case data == "tag_production":
tag := "production"
s.ctx.Tag = &tag
s.Enter(b, bot.EditMessage)
case data == "cancel_edit":
s.Enter(b, bot.EditMessage)
case data == "confirm_create":
s.ctx.createCreative(b)
case strings.HasPrefix(data, "delete_button:"):
@@ -428,10 +440,16 @@ func (s *AddCreativeCtx) createCreative(b *bot.Bot) {
log.Info().Str("text", *s.Text).Msg("Creative text")
tag := "testing"
if s.Tag != nil {
tag = *s.Tag
}
input := backend.CreateCreativeInput{
Name: *s.Name,
Text: *s.Text,
Buttons: buttons,
Tag: &tag,
}
if len(mediaItems) > 0 {
input.MediaItems = mediaItems

View File

@@ -60,6 +60,9 @@ func (s *CreativeDetails) Enter(b *bot.Bot, mode bot.RenderMode) {
for _, btn := range creative.Buttons {
s.Buttons = append(s.Buttons, InlineButton{Text: btn.Text, URL: btn.URL})
}
if creative.Tag != "" {
s.Tag = &creative.Tag
}
s.MediaChanged = false
s.ClearInputMode()
@@ -109,6 +112,19 @@ func (s *CreativeDetails) HandleCallback(b *bot.Bot, u *echotron.Update) {
s.UpdateCreativePreview(b)
s.showManagementPanelWithDelete(b)
case data == "edit_tag":
s.ShowTagPanel(b)
case data == "tag_testing":
tag := "testing"
s.Tag = &tag
s.showManagementPanelWithDelete(b)
case data == "tag_production":
tag := "production"
s.Tag = &tag
s.showManagementPanelWithDelete(b)
case data == "cancel_add_button":
// Отменяем добавление кнопки
s.CancelPendingButton(b)
@@ -293,6 +309,7 @@ func (s *CreativeDetails) updateCreative(b *bot.Bot) {
input := backend.UpdateCreativeInput{
Name: s.Name,
Text: s.Text,
Tag: s.Tag,
}
if s.MediaChanged {
if len(s.MediaItems) > 0 {

View File

@@ -31,6 +31,7 @@ type CreativeEditorFields struct {
Name *string
Text *string
Buttons []InlineButton
Tag *string // "testing" or "production"
// Медиа
MediaItems []MediaItem
@@ -663,6 +664,9 @@ func (e *CreativeEditorFields) BuildEditorButtons(confirmText, confirmCallback,
}
buttons = append(buttons, Row(Button(addButtonLabel, addButtonCallback)))
// Кнопка выбора тега
buttons = append(buttons, Row(Button(e.GetTagLabel(), "edit_tag")))
// Кнопка удаления медиа (если медиа добавлено)
if len(e.MediaItems) > 0 {
label := "⌫ Убрать медиа"

View File

@@ -58,6 +58,42 @@ URL должен начинаться с <code>http://</code> или <code>https
`
const msgEditTag = `
<b>🏷 Выберите тег креатива:</b>
🧪 <b>Тестовый</b> — для A/B тестов и экспериментов
🚀 <b>Рабочий</b> — проверенный эффективный креатив
`
func (e *CreativeEditorFields) ShowTagPanel(b *bot.Bot) {
testingLabel := "🧪 Тестовый"
productionLabel := "🚀 Рабочий"
if e.Tag != nil {
if *e.Tag == "testing" {
testingLabel = "✓ 🧪 Тестовый"
} else if *e.Tag == "production" {
productionLabel = "✓ 🚀 Рабочий"
}
}
e.ShowControlPanel(b, msgEditTag, [][]echotron.InlineKeyboardButton{
Row(
Button(testingLabel, "tag_testing"),
Button(productionLabel, "tag_production"),
),
Row(Button("« Назад", "cancel_edit")),
})
}
func (e *CreativeEditorFields) GetTagLabel() string {
if e.Tag != nil && *e.Tag == "production" {
return "🏷 Рабочий"
}
return "🏷 Тестовый"
}
func (e *CreativeEditorFields) ShowAddButtonPanel(b *bot.Bot) {
inviteLabel := "Ссылка на канал"
customLabel := "Своя ссылка"