update
This commit is contained in:
parent
52731baaca
commit
ec472f92bb
1 changed files with 11 additions and 9 deletions
20
main.py
20
main.py
|
@ -140,8 +140,8 @@ height=\"32\" src=\"{emote_}\" data-mx-emoticon />"""
|
||||||
"msgtype": "m.text"
|
"msgtype": "m.text"
|
||||||
}
|
}
|
||||||
|
|
||||||
content["body"], content["formatted_body"] = message, await \
|
content["body"], content["formatted_body"] = message, \
|
||||||
self.process_emotes(message, emotes)
|
await self.process_emotes(message, emotes)
|
||||||
|
|
||||||
if reply_id:
|
if reply_id:
|
||||||
reply_event = await self.room_get_event(
|
reply_event = await self.room_get_event(
|
||||||
|
@ -153,21 +153,19 @@ height=\"32\" src=\"{emote_}\" data-mx-emoticon />"""
|
||||||
"m.in_reply_to": {"event_id": reply_id},
|
"m.in_reply_to": {"event_id": reply_id},
|
||||||
}
|
}
|
||||||
|
|
||||||
content["format"] = "org.matrix.custom.html"
|
|
||||||
|
|
||||||
content["formatted_body"] = f"""<mx-reply><blockquote>\
|
content["formatted_body"] = f"""<mx-reply><blockquote>\
|
||||||
<a href="https://matrix.to/#/{room_id}/{reply_id}">In reply to</a>\
|
<a href="https://matrix.to/#/{room_id}/{reply_id}">In reply to</a>\
|
||||||
<a href="https://matrix.to/#/{reply_event.sender}">{reply_event.sender}</a>\
|
<a href="https://matrix.to/#/{reply_event.sender}">{reply_event.sender}</a>\
|
||||||
<br>{reply_event.body}</blockquote></mx-reply>{content["formatted_body"]}"""
|
<br>{reply_event.body}</blockquote></mx-reply>{content["formatted_body"]}"""
|
||||||
|
|
||||||
if edit_id:
|
if edit_id:
|
||||||
content["body"] = f" * {message}"
|
content["body"] = f" * {content['body']}"
|
||||||
|
|
||||||
content["m.new_content"] = {
|
content["m.new_content"] = {
|
||||||
"body": message,
|
"body": content["body"],
|
||||||
"formatted_body": content["formatted_body"],
|
"formatted_body": content["formatted_body"],
|
||||||
"format": "org.matrix.custom.html",
|
"format": content["format"],
|
||||||
"msgtype": "m.text"
|
"msgtype": content["msgtype"]
|
||||||
}
|
}
|
||||||
|
|
||||||
content["m.relates_to"] = {
|
content["m.relates_to"] = {
|
||||||
|
@ -193,9 +191,11 @@ height=\"32\" src=\"{emote_}\" data-mx-emoticon />"""
|
||||||
event_id, channel_id, embed=None):
|
event_id, channel_id, embed=None):
|
||||||
channel = channel_store[channel_id]
|
channel = channel_store[channel_id]
|
||||||
|
|
||||||
# Create webhook if it doesn't exist
|
|
||||||
hook_name = "matrix_bridge"
|
hook_name = "matrix_bridge"
|
||||||
|
|
||||||
hooks = await channel.webhooks()
|
hooks = await channel.webhooks()
|
||||||
|
|
||||||
|
# Create webhook if it doesn't exist
|
||||||
hook = discord.utils.get(hooks, name=hook_name)
|
hook = discord.utils.get(hooks, name=hook_name)
|
||||||
if not hook:
|
if not hook:
|
||||||
hook = await channel.create_webhook(name=hook_name)
|
hook = await channel.create_webhook(name=hook_name)
|
||||||
|
@ -207,6 +207,7 @@ height=\"32\" src=\"{emote_}\" data-mx-emoticon />"""
|
||||||
username=author[:80], avatar_url=avatar,
|
username=author[:80], avatar_url=avatar,
|
||||||
content=message, embed=embed, wait=True
|
content=message, embed=embed, wait=True
|
||||||
)
|
)
|
||||||
|
|
||||||
message_store[event_id] = hook
|
message_store[event_id] = hook
|
||||||
message_store[hook.id] = event_id
|
message_store[hook.id] = event_id
|
||||||
except discord.errors.HTTPException as e:
|
except discord.errors.HTTPException as e:
|
||||||
|
@ -380,6 +381,7 @@ class Callbacks(object):
|
||||||
message = await self.process_message(message, channel_id)
|
message = await self.process_message(message, channel_id)
|
||||||
|
|
||||||
embed = None
|
embed = None
|
||||||
|
|
||||||
# Get attachments
|
# Get attachments
|
||||||
try:
|
try:
|
||||||
attachment = event.url.split("/")[-1]
|
attachment = event.url.split("/")[-1]
|
||||||
|
|
Loading…
Reference in a new issue