Friend cmds: Use same mention formatting as outbound message formatter

This commit is contained in:
Andrew Ferrazzutti 2022-05-09 03:24:11 -04:00
parent a49e2768a3
commit 37101f42c1
1 changed files with 5 additions and 5 deletions

View File

@ -19,7 +19,7 @@ from typing import TYPE_CHECKING, Awaitable
import asyncio
from mautrix.bridge.commands import HelpSection, command_handler
from mautrix.types import SerializerError
from mautrix.types import Format, SerializerError
from mautrix.util import utf16_surrogate
from mautrix.util.formatter import (
EntityString,
@ -237,10 +237,10 @@ async def _edit_friend(evt: CommandEvent, add: bool) -> None:
if not evt.args:
await evt.reply(f"**Usage:** `$cmdprefix+sp {evt.command} <KakaoTalk ID|Matrix user ID>`")
return
formatted_body = evt.content.get("formatted_body")
if formatted_body:
arg = formatted_body[len(evt.command):].strip()
parsed = await MentionParser().parse(utf16_surrogate.add(arg))
if evt.content.get("format", None) == Format.HTML and evt.content["formatted_body"]:
parsed = await MentionParser().parse(utf16_surrogate.add(
evt.content["formatted_body"][len(evt.command):].strip()
))
if not parsed.entities:
await evt.reply("No user found")
return