Skip to content

Magic I wrote a year ago#2557

Closed
coder2020official wants to merge 1 commit into
eternnoir:masterfrom
coder2020official:formatting-fix
Closed

Magic I wrote a year ago#2557
coder2020official wants to merge 1 commit into
eternnoir:masterfrom
coder2020official:formatting-fix

Conversation

@coder2020official

Copy link
Copy Markdown
Collaborator

No description provided.

@coder2020official

Copy link
Copy Markdown
Collaborator Author

@Badiboy this was what I wrote some time ago; Tested now (not rigorously) -- works; Could you test, too?

@coder2020official

Copy link
Copy Markdown
Collaborator Author

Tests failed because of existing pre-check of this function; The new output seems to be giving the same effect

@Badiboy

Badiboy commented Feb 14, 2026

Copy link
Copy Markdown
Collaborator

I'll take a look

@Badiboy

Badiboy commented Feb 14, 2026

Copy link
Copy Markdown
Collaborator
        # Handle different entity types
        if entity_type == "text_mention" and hasattr(entity, 'user'):
            return f"<a href=\"tg://user?id={entity.user.id}\">{content}</a>"
        # elif entity_type == "mention":
        #     username = content[1:]  # Remove @ symbol
        #     return f"<a href=\"https://t.me/{username}\">{content}</a>"
        elif entity_type == "text_link" and hasattr(entity, 'url'):
            return f"<a href=\"{entity.url}\">{content}</a>"
        elif entity_type == "custom_emoji" and hasattr(entity, 'custom_emoji_id'):
            return f"<tg-emoji emoji-id=\"{entity.custom_emoji_id}\">{content}</tg-emoji>"
        elif (entity_type == "pre" and hasattr(entity, 'language') and entity.language):
            return f"<pre><code class=\"language-{entity.language}\">{content}</code></pre>"
        elif entity_type in _subs:
            template = _subs[entity_type]
            return template.format(text=content)

With thise fixes looks also working. I'll extend the alternatives and can start from testing this.

@Badiboy Badiboy closed this Feb 21, 2026
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.

2 participants