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.dev3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0544fed818897a75ad5eeef18bdb04677f74329c3701334c40631cc2276fe30 |
|
MD5 | 6fdc512534194ee1d4cb99a1ea127d5b |
|
BLAKE2b-256 | 05db9fad65acd88dc90652af29adc6caf32c45f93b53ead497faba4dbaab3899 |
Close
Hashes for dimentyy_tl_parse-0.0.1.dev3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe4bff1c5ba2c5277b573afedcb33c45d707432add39255870b72f1ab4e59f5c |
|
MD5 | e0a9349a250125a60e3edee88ddcd38f |
|
BLAKE2b-256 | 55c3e996036ce8a4e26c2ef20bd3ae9c00a06161c03efacb9001d1058caefce8 |