From c5cedd880d49b7546599078e1884b81b8f312b5a Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 15 Oct 2018 14:29:23 +0200 Subject: [PATCH] Allow Markdown and HTML styles to work on an empty dict. For inline results. User mentions are disabled this way --- pyrogram/client/style/html.py | 4 ++-- pyrogram/client/style/markdown.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyrogram/client/style/html.py b/pyrogram/client/style/html.py index 63a80733..4cafeb35 100644 --- a/pyrogram/client/style/html.py +++ b/pyrogram/client/style/html.py @@ -34,8 +34,8 @@ class HTML: HTML_RE = re.compile(r"<(\w+)(?: href=([\"'])([^<]+)\2)?>([^>]+)") MENTION_RE = re.compile(r"tg://user\?id=(\d+)") - def __init__(self, peers_by_id): - self.peers_by_id = peers_by_id + def __init__(self, peers_by_id: dict = None): + self.peers_by_id = peers_by_id or {} def parse(self, text): entities = [] diff --git a/pyrogram/client/style/markdown.py b/pyrogram/client/style/markdown.py index 7a67d0ae..61b60e17 100644 --- a/pyrogram/client/style/markdown.py +++ b/pyrogram/client/style/markdown.py @@ -51,8 +51,8 @@ class Markdown: )) MENTION_RE = re.compile(r"tg://user\?id=(\d+)") - def __init__(self, peers_by_id: dict): - self.peers_by_id = peers_by_id + def __init__(self, peers_by_id: dict = None): + self.peers_by_id = peers_by_id or {} def parse(self, message: str): message = utils.add_surrogates(message).strip()