From eef7721153c962cb3a0285966f6b1bd0596e123d Mon Sep 17 00:00:00 2001 From: git-bruh Date: Tue, 18 May 2021 13:34:42 +0530 Subject: [PATCH] try reconnecting, remove useless stuff --- appservice/gateway.py | 5 +---- appservice/main.py | 11 +++-------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/appservice/gateway.py b/appservice/gateway.py index 7fd2c08..5610d48 100644 --- a/appservice/gateway.py +++ b/appservice/gateway.py @@ -33,9 +33,7 @@ class Gateway: websockets.ConnectionClosedError, websockets.InvalidMessage, ): - # TODO reconnect - self.logger.exception("Quitting, connection lost.") - break + self.logger.exception("Connection lost, reconnecting.") # Stop sending heartbeats until we reconnect. if self.heartbeat_task and not self.heartbeat_task.cancelled(): @@ -117,7 +115,6 @@ class Gateway: elif otype == "GUILD_EMOJIS_UPDATE": obj = discord.GuildEmojisUpdate(data) else: - self.logger.info(f"Unknown OTYPE: {otype}") return func = getattr(self, f"on_{otype.lower()}", None) diff --git a/appservice/main.py b/appservice/main.py index e830462..0909b85 100644 --- a/appservice/main.py +++ b/appservice/main.py @@ -99,9 +99,6 @@ class MatrixClient(AppService): author = self.get_members(message.room_id)[message.sender] - if not author.display_name: - author.display_name = message.sender - webhook = self.discord.get_webhook( channel_id, self.discord.webhook_name ) @@ -129,7 +126,7 @@ class MatrixClient(AppService): webhook, self.mxc_url(author.avatar_url), message.body, - author.display_name, + author.display_name if author.display_name else message.sender, ).id with Cache.lock: @@ -207,9 +204,7 @@ class MatrixClient(AppService): reference: discord.MessageReference = None, ) -> dict: content = { - # Replace single newlines with double newlines so that clients - # render them properly. - "body": re.sub("\\b\n\\b", "\n\n", message), + "body": message, "format": "org.matrix.custom.html", "msgtype": "m.text", "formatted_body": self.get_fmt(message, emotes), @@ -239,7 +234,7 @@ class MatrixClient(AppService): content = { **content, "body": ( - f"> <{event.sender}> {event.body}\n\n{content['body']}" + f"> <{event.sender}> {event.body}\n{content['body']}" ), "m.relates_to": {"m.in_reply_to": {"event_id": event.id}}, "formatted_body": f"""
\