Skip to main content

Better parsing modes for telethon.TelegramClient

Project description

Parsing library

Absolute bloatware. 🚀

from telethon import TelegramClient
from dimentyy.tl.parse import HTML

client: TelegramClient = ...

client.parse_mode = HTML(client)  # two ways of applying
parser = HTML.applied_to(client)  # preferred

# From now on, every message will be handled by the 
# new parser. It resembles default "HTML", but with
# some new features such as mentions and spoilers!

Installation

pip install dimentyy.tl-parse

  • Correct offset & length

Text formatting won't be offset! Using len() will actually result in the wrong length if the text contains some specific Unicode characters, such as some emojis.

  • Mentions

<!-- Telethon version, a little unreadable, right? -->
<a href="tg://user?id=490288812">dimentyy</a>

<!-- Uses real mention without replacing <a> when sending -->
<mention user_id=490288812>dimentyy</mention>
  • Spoilers

<spoiler>I will never update burger-bot</spoiler>

<!-- Consistent name -->
  • <custom_emoji document_id=123></custom_emoji> (needs testing!)

Features to come:

  • Unparsing
  • Fixing improper entities order (testing)
<!-- Some clients will display that incorrectly, event -->
<b>BOLD. <i>BOTH.</b> ITALIC.</i> <!-- Even GitHub won't highlight </i> -->

<!-- So, this feature will fix that -->
<b>BOLD. <i>BOTH.</i></b><i> ITALIC.</i>
MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dimentyy_tl_parse-0.0.1.dev3.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

dimentyy_tl_parse-0.0.1.dev3-py2.py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page