From cf2358dbe884f66ceb7474daee102d8ac1a2fbaa Mon Sep 17 00:00:00 2001 From: git-bruh Date: Thu, 10 Dec 2020 17:56:00 +0530 Subject: [PATCH] Webhook messages can now be edited (https://github.com/Rapptz/discord.py/issues/6058) --- README.md | 2 +- main.py | 10 ++++++++++ requirements.txt | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 593f022..c255ee1 100644 --- a/README.md +++ b/README.md @@ -21,5 +21,5 @@ NOTE: [Privileged Intents](https://discordpy.readthedocs.io/en/latest/intents.ht - [x] Attachments (Converted to URLs) - [x] Typing status (Not very accurate) - [x] Redacting messages -- [x] Editing messages (Partial, see [this issue](https://github.com/Rapptz/discord.py/issues/6058)) +- [x] Editing messages - [x] Replies diff --git a/main.py b/main.py index e03a759..35e0237 100644 --- a/main.py +++ b/main.py @@ -255,6 +255,16 @@ class Callbacks(object): homeserver = event.sender.split(":")[-1] url = "https://matrix.org/_matrix/media/r0/download" + try: + if content_dict["m.relates_to"]["rel_type"] == "m.replace": + edited_event = content_dict["m.relates_to"]["event_id"] + edited_content = content_dict["m.new_content"]["body"] + webhook_message = message_store[edited_event] + await webhook_message.edit(content=edited_content) + return + except KeyError: + pass + try: if content_dict["m.relates_to"]["m.in_reply_to"]["event_id"] in \ message_store.values(): diff --git a/requirements.txt b/requirements.txt index cd4f837..1adeabd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -discord.py==1.5.1 +git+git://github.com/rapptz/discord.py@44dc7a8 matrix-nio==0.15.2