Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[FEATURE] Convenience Method forMessageEntity Concatenation #4372

@Bibo-Joshi

Description

@Bibo-Joshi

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

The discussion with TG intdlib/telegram-bot-api#515 has made it clear that we should encourage users to work more with MessageEntities rather than with ourtext_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 intdlib/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 ofby 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. UsesME.shift_entities internally

Describe alternatives you've considered

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

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp