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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for dimentyy_tl_parse-0.0.1.dev5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e68e791e8fb5022baeb5bf76b645254692bc412655b8aca2fc48652c96769380 |
|
MD5 | 8954a849be4bb9e0253c0eedfe213560 |
|
BLAKE2b-256 | b0be6c2a694ee8a0611c92bb56b0a923d6d25066b30ba0cec3155efd21e12a6f |
Close
Hashes for dimentyy_tl_parse-0.0.1.dev5-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9c464e4450e8c9959d545f2228ca093efacc1e1e78e8e8f7008b7d45fe8a94a |
|
MD5 | f009aa066fc9cc1f07db5e56d4e00eaf |
|
BLAKE2b-256 | 1899210f8bbc3346a657f4ca483cdc10c8948ca38748de2e5c238f64c6c5d563 |