Allow Markdown and HTML styles to work on an empty dict.

For inline results. User mentions are disabled this way
This commit is contained in:
Dan 2018-10-15 14:29:23 +02:00
parent e59d07af1e
commit c5cedd880d
2 changed files with 4 additions and 4 deletions

View File

@ -34,8 +34,8 @@ class HTML:
HTML_RE = re.compile(r"<(\w+)(?: href=([\"'])([^<]+)\2)?>([^>]+)</\1>") HTML_RE = re.compile(r"<(\w+)(?: href=([\"'])([^<]+)\2)?>([^>]+)</\1>")
MENTION_RE = re.compile(r"tg://user\?id=(\d+)") MENTION_RE = re.compile(r"tg://user\?id=(\d+)")
def __init__(self, peers_by_id): def __init__(self, peers_by_id: dict = None):
self.peers_by_id = peers_by_id self.peers_by_id = peers_by_id or {}
def parse(self, text): def parse(self, text):
entities = [] entities = []

View File

@ -51,8 +51,8 @@ class Markdown:
)) ))
MENTION_RE = re.compile(r"tg://user\?id=(\d+)") MENTION_RE = re.compile(r"tg://user\?id=(\d+)")
def __init__(self, peers_by_id: dict): def __init__(self, peers_by_id: dict = None):
self.peers_by_id = peers_by_id self.peers_by_id = peers_by_id or {}
def parse(self, message: str): def parse(self, message: str):
message = utils.add_surrogates(message).strip() message = utils.add_surrogates(message).strip()