Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim telegram audio captions to 1024 symbols #52

Merged
merged 1 commit into from Mar 24, 2022
Merged

Conversation

paskal
Copy link
Sponsor Collaborator

@paskal paskal commented Mar 24, 2022

That PR allows posting audio with long captions to Telegram.

Copy link
Owner

@umputun umputun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple of minor things

@@ -75,7 +75,7 @@ func (client TelegramClient) Send(channelID string, item feed.Item) (err error)
func (client TelegramClient) sendText(channelID string, item feed.Item) (*tb.Message, error) {
message, err := client.Bot.Send(
recipient{chatID: channelID},
client.getMessageHTML(item, true),
client.getMessageHTML(item, true, false),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a small suggestion: having two bool params one after another is hard to reason about, especially without IDE help. Adding a small private struct like sendParams and passing it, will make things more readable

messageHTML := description

func (client TelegramClient) getMessageHTML(item feed.Item, withMp3Link, trimCaption bool) string {
var header, footer string
title := strings.TrimSpace(item.Title)
if title != "" {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this if/switch construct is a little bit award. Isn't all of this just a couple of ifs? i.e. title != "" && item.Link == "" and title != "" && item.Link != ""

@umputun
Copy link
Owner

umputun commented Mar 24, 2022

I'll merge it as it solves a real problem. Feel free to adress comments as you have a moment

@umputun umputun merged commit 31abbc6 into master Mar 24, 2022
@umputun umputun deleted the paskal/trim_captions branch March 24, 2022 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants