Skip to content

Commit

Permalink
Fix caption (#3)
Browse files Browse the repository at this point in the history
* refactor: Set caption to enhancedPrompt in HandleCommand

* fix: Ensure caption length is within Telegram limits
  • Loading branch information
azalio authored Dec 31, 2024
1 parent 2ee6650 commit b6e63b5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/service/bot_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ func (s *BotServiceImpl) HandleCommand(ctx context.Context, command string, args
})
// Fallback to the original prompt in case of error
enhancedPrompt = args
caption = enhancedPrompt

// Ensure caption length is within Telegram limits
if len(caption) > 1024 {
caption = caption[:1024]
}
}

// Generate an image using the enhanced prompt
Expand Down Expand Up @@ -147,6 +153,10 @@ func (s *BotServiceImpl) SendPhoto(ctx context.Context, chatID int64, photo []by
Bytes: photo,
})

// Ensure caption length is within Telegram limits
if len(caption) > 1024 {
caption = caption[:1024]
}
photoMsg.Caption = caption

_, err := s.Bot.Send(photoMsg)
Expand Down

0 comments on commit b6e63b5

Please sign in to comment.