try reconnecting, remove useless stuff

This commit is contained in:
git-bruh 2021-05-18 13:34:42 +05:30
parent a3ee85d955
commit eef7721153
No known key found for this signature in database
GPG key ID: E1475C50075ADCE6
2 changed files with 4 additions and 12 deletions

View file

@ -33,9 +33,7 @@ class Gateway:
websockets.ConnectionClosedError, websockets.ConnectionClosedError,
websockets.InvalidMessage, websockets.InvalidMessage,
): ):
# TODO reconnect self.logger.exception("Connection lost, reconnecting.")
self.logger.exception("Quitting, connection lost.")
break
# Stop sending heartbeats until we reconnect. # Stop sending heartbeats until we reconnect.
if self.heartbeat_task and not self.heartbeat_task.cancelled(): if self.heartbeat_task and not self.heartbeat_task.cancelled():
@ -117,7 +115,6 @@ class Gateway:
elif otype == "GUILD_EMOJIS_UPDATE": elif otype == "GUILD_EMOJIS_UPDATE":
obj = discord.GuildEmojisUpdate(data) obj = discord.GuildEmojisUpdate(data)
else: else:
self.logger.info(f"Unknown OTYPE: {otype}")
return return
func = getattr(self, f"on_{otype.lower()}", None) func = getattr(self, f"on_{otype.lower()}", None)

View file

@ -99,9 +99,6 @@ class MatrixClient(AppService):
author = self.get_members(message.room_id)[message.sender] author = self.get_members(message.room_id)[message.sender]
if not author.display_name:
author.display_name = message.sender
webhook = self.discord.get_webhook( webhook = self.discord.get_webhook(
channel_id, self.discord.webhook_name channel_id, self.discord.webhook_name
) )
@ -129,7 +126,7 @@ class MatrixClient(AppService):
webhook, webhook,
self.mxc_url(author.avatar_url), self.mxc_url(author.avatar_url),
message.body, message.body,
author.display_name, author.display_name if author.display_name else message.sender,
).id ).id
with Cache.lock: with Cache.lock:
@ -207,9 +204,7 @@ class MatrixClient(AppService):
reference: discord.MessageReference = None, reference: discord.MessageReference = None,
) -> dict: ) -> dict:
content = { content = {
# Replace single newlines with double newlines so that clients "body": message,
# render them properly.
"body": re.sub("\\b\n\\b", "\n\n", message),
"format": "org.matrix.custom.html", "format": "org.matrix.custom.html",
"msgtype": "m.text", "msgtype": "m.text",
"formatted_body": self.get_fmt(message, emotes), "formatted_body": self.get_fmt(message, emotes),
@ -239,7 +234,7 @@ class MatrixClient(AppService):
content = { content = {
**content, **content,
"body": ( "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}}, "m.relates_to": {"m.in_reply_to": {"event_id": event.id}},
"formatted_body": f"""<mx-reply><blockquote>\ "formatted_body": f"""<mx-reply><blockquote>\