From 0a14aa1bc6e95b47cb355c6a8c709645be04ab05 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Mon, 30 Oct 2017 10:56:39 +0100 Subject: [PATCH] Remove additional check when calculating emojies length This special check treated some emojies as 3 characters long but this shouldn't have actually been done, likely due to the old regex matching more things as emoji than it should (which would have count as 2 too, making up for 1+3 from the new is_emoji()). --- telethon/extensions/markdown.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/telethon/extensions/markdown.py b/telethon/extensions/markdown.py index 078736a2..432b1452 100644 --- a/telethon/extensions/markdown.py +++ b/telethon/extensions/markdown.py @@ -91,15 +91,10 @@ def is_emoji(char): def emojiness(char): """ - Returns the "emojiness" of an emoji, or how many characters it counts as. - 1 if it's not an emoji, 2 usual, 3 "special" (seem to count more). + Returns 2 if the character is an emoji, or 1 otherwise. + This seems to be the length Telegram uses for offsets and lengths. """ - if not is_emoji(char): - return 1 - if ord(char) < 129296: - return 2 - else: - return 3 + return 2 if is_emoji(char) else 1 def parse(message, delimiters=None, url_re=None):