diff --git a/stdplugins/markdown.py b/stdplugins/markdown.py index e3e752b..1109f2a 100644 --- a/stdplugins/markdown.py +++ b/stdplugins/markdown.py @@ -20,19 +20,22 @@ def parse_url_match(m): return m.group(1), entity -PRINTABLE_ASCII = range(0x21, 0x7f) def parse_aesthetics(m): def aesthetify(string): for c in string: - c = ord(c) - if c in PRINTABLE_ASCII: - c += 0xFF00 - 0x20 - elif c == ord(" "): - c = 0x3000 - yield chr(c) + if " " < c <= "~": + yield chr(ord(c) + 0xFF00 - 0x20) + elif c == " ": + yield "\u3000" + else: + yield c return "".join(aesthetify(m[1])), None +def parse_strikethrough(m): + return ("\u0336".join(m[1]) + "\u0336"), None + + def parse_subreddit(m): text = '/' + m.group(3) entity = MessageEntityTextUrl( @@ -59,6 +62,7 @@ def parse_snip(m): MATCHERS = [ (DEFAULT_URL_RE, parse_url_match), (re.compile(r'\+\+(.+?)\+\+'), parse_aesthetics), + (re.compile(r'~~(.+?)~~'), parse_strikethrough), (re.compile(r'([^/\w]|^)(/?(r/\w+))'), parse_subreddit), (re.compile(r'(!\w+)'), parse_snip) ] @@ -79,6 +83,8 @@ def parse(message, old_entities=None): # Skip already existing entities if we're at one if i == e.offset: i += e.length + else: + after += 1 # Find the first pattern that matches for pattern, parser in MATCHERS: diff --git a/stdplugins/who.py b/stdplugins/who.py index 309008f..e4f5349 100644 --- a/stdplugins/who.py +++ b/stdplugins/who.py @@ -22,6 +22,6 @@ async def _(event): who_string = utils.get_display_name(who) if isinstance(who, (types.User, types.Channel)) and who.username: who_string += f" (@{who.username})" - who_string += f", #{who.id}" + who_string += f", [#{who.id}](tg://user?id={who.id})" await event.edit(who_string) diff --git a/uniborg/_core.py b/uniborg/_core.py index 4679ec3..7475028 100644 --- a/uniborg/_core.py +++ b/uniborg/_core.py @@ -10,7 +10,7 @@ from uniborg import util DELETE_TIMEOUT = 2 -@borg.on(util.admin_cmd(r"^\.load (?P\w+)$")) +@borg.on(util.admin_cmd(r"^\.(?:re)?load (?P\w+)$")) async def load_reload(event): await event.delete() shortname = event.pattern_match["shortname"] diff --git a/uniborg/storage.py b/uniborg/storage.py index 70fda9b..2cff9e2 100644 --- a/uniborg/storage.py +++ b/uniborg/storage.py @@ -48,6 +48,6 @@ class Storage: def _save(self): if not self._root.is_dir(): - self._root(parents=True, exist_ok=True) + self._root.mkdir(parents=True, exist_ok=True) with open(self._root / FILE_NAME, 'w') as fp: json.dump(self._data, fp)