8000 [FEATURE] Convenience Method for `MessageEntity` Concatenation · Issue #4372 · python-telegram-bot/python-telegram-bot · GitHub
[go: up one dir, main page]

Skip to content

[FEATURE] Convenience Method for MessageEntity Concatenation #4372

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

Closed
Bibo-Joshi opened this issue Jul 12, 2024 · 0 comments · Fixed by #4376
Closed

[FEATURE] Convenience Method for MessageEntity Concatenation #4372

Bibo-Joshi opened this issue Jul 12, 2024 · 0 comments · Fixed by #4376

Comments

@Bibo-Joshi
Copy link
Member

What kind of feature are you missing? Where do you notice a shortcoming of PTB?

The discussion with TG in tdlib/telegram-bot-api#515 has made it clear that we should encourage users to work more with MessageEntities rather than with our text_html/markdown helpers. Since this is sometimes cumbersome, convenience functionality for working with ME is surely advisable and we've made a step into that direction with #4323 .

What I'd like to see in addition is convenience functionality for catenating text with entities as initially touched in tdlib/telegram-bot-api#515 (comment)

Describe the solution you'd like

new class methods

  • ME.shift_entities(entities: Sequence[ME], by: str | int) -> Sequence[ME]: shifts the entities by the specified length or the utf-16 length of the string of by is a string. This would be useful for adding a prefix to a message with entities
  • ME.concatetane(first: tuple[str, Sequence[ME]], second: tuple[str, Sequence[ME]]) -> tuple[str, Sequence[ME]]: Concatenates text and entities. Uses ME.shift_entities internally

Describe alternatives you've considered

ME.concatenate could be skipped in a first step as it can be implemented using shift_entities

Additional context

No response

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant
0