Update matrix message redaction
This commit is contained in:
parent
00b8ec8474
commit
29d93658b3
1 changed files with 6 additions and 9 deletions
15
main.py
15
main.py
|
@ -34,8 +34,6 @@ intents.members = True
|
||||||
discord_client = discord.Client(intents=intents)
|
discord_client = discord.Client(intents=intents)
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
|
|
||||||
deletion_queue = []
|
|
||||||
message_cache = {}
|
message_cache = {}
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,12 +51,6 @@ async def on_message(message):
|
||||||
if message.author.bot:
|
if message.author.bot:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Delete redacted messages
|
|
||||||
for webhook_message in deletion_queue:
|
|
||||||
message_ = message_cache[webhook_message]
|
|
||||||
await message_.delete()
|
|
||||||
deletion_queue.remove(webhook_message)
|
|
||||||
|
|
||||||
# Replace Discord IDs with mentions and emotes
|
# Replace Discord IDs with mentions and emotes
|
||||||
content = await process_discord(message.content)
|
content = await process_discord(message.content)
|
||||||
|
|
||||||
|
@ -275,7 +267,12 @@ async def redaction_callback(room, event):
|
||||||
if event.sender == matrix_client.user:
|
if event.sender == matrix_client.user:
|
||||||
return
|
return
|
||||||
|
|
||||||
deletion_queue.append(event.redacts)
|
# Redact webhook message
|
||||||
|
try:
|
||||||
|
message = message_cache[event.redacts]
|
||||||
|
await message.delete()
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
async def typing_callback(room, event):
|
async def typing_callback(room, event):
|
||||||
|
|
Loading…
Reference in a new issue