Merge branch 'master' into mautrix-0.4
This commit is contained in:
@@ -169,7 +169,9 @@ class MatrixParser:
|
||||
|
||||
@classmethod
|
||||
def node_to_tmessage(cls, node: HTMLNode, ctx: RecursionContext) -> TelegramMessage:
|
||||
if node.tag == "ol":
|
||||
if node.tag == "mx-reply":
|
||||
return TelegramMessage("")
|
||||
elif node.tag == "ol":
|
||||
return cls.list_to_tmessage(node, ctx)
|
||||
elif node.tag == "ul":
|
||||
return cls.list_to_tmessage(node, ctx.enter_list())
|
||||
|
||||
@@ -1033,7 +1033,6 @@ class Portal:
|
||||
orig_msg = DBMessage.get_by_mxid(relates_to.get("event_id", ""), self.mxid, space)
|
||||
if orig_msg and "m.new_content" in message:
|
||||
message = message["m.new_content"]
|
||||
formatter.matrix_reply_to_telegram(message, space, room_id=self.mxid)
|
||||
response = await client.edit_message(self.peer, orig_msg.tgid, message,
|
||||
parse_mode=self._matrix_event_to_entities,
|
||||
link_preview=lp)
|
||||
|
||||
@@ -170,14 +170,26 @@ class Puppet(CustomPuppetMixin):
|
||||
return int(round(similarity * 100))
|
||||
|
||||
@staticmethod
|
||||
def get_displayname(info: User, enable_format: bool = True) -> str:
|
||||
def _filter_name(name: str) -> str:
|
||||
if not name:
|
||||
return ""
|
||||
whitespace = ("\ufeff", "\u3164", "\u2063", "\u200b", "\u180e", "\u034f", "\u2800",
|
||||
"\u180e", "\u200b", "\u202f", "\u205f", "\u3000")
|
||||
name = "".join(char for char in name if char not in whitespace)
|
||||
name = name.strip()
|
||||
return name
|
||||
|
||||
@classmethod
|
||||
def get_displayname(cls, info: User, enable_format: bool = True) -> str:
|
||||
fn = cls._filter_name(info.first_name)
|
||||
ln = cls._filter_name(info.last_name)
|
||||
data = {
|
||||
"phone number": info.phone if hasattr(info, "phone") else None,
|
||||
"username": info.username,
|
||||
"full name": " ".join([info.first_name or "", info.last_name or ""]).strip(),
|
||||
"full name reversed": " ".join([info.first_name or "", info.last_name or ""]).strip(),
|
||||
"first name": info.first_name,
|
||||
"last name": info.last_name,
|
||||
"full name": " ".join([fn, ln]).strip(),
|
||||
"full name reversed": " ".join([ln, fn]).strip(),
|
||||
"first name": fn,
|
||||
"last name": ln,
|
||||
}
|
||||
preferences = config["bridge.displayname_preference"]
|
||||
name = None
|
||||
@@ -189,7 +201,7 @@ class Puppet(CustomPuppetMixin):
|
||||
if isinstance(info, User) and info.deleted:
|
||||
name = f"Deleted account {info.id}"
|
||||
elif not name:
|
||||
name = info.id
|
||||
name = str(info.id)
|
||||
|
||||
if not enable_format:
|
||||
return name
|
||||
|
||||
Reference in New Issue
Block a user