|
48 | 48 | ) |
49 | 49 | from core.thread import ThreadManager |
50 | 50 | from core.time import human_timedelta |
51 | | -from core.utils import extract_block_timestamp, normalize_alias, parse_alias, truncate, tryint, human_join |
| 51 | +from core.utils import ( |
| 52 | + extract_block_timestamp, |
| 53 | + normalize_alias, |
| 54 | + parse_alias, |
| 55 | + truncate, |
| 56 | + tryint, |
| 57 | + human_join, |
| 58 | + extract_forwarded_content, |
| 59 | +) |
52 | 60 |
|
53 | 61 | logger = getLogger(__name__) |
54 | 62 |
|
@@ -169,7 +177,7 @@ def startup(self): |
169 | 177 | logger.info("v%s", __version__) |
170 | 178 | logger.info("Authors: kyb3r, fourjr, Taaku18") |
171 | 179 | logger.line() |
172 | | - logger.info("discord.py: v2.5.2") |
| 180 | + logger.info("discord.py: v2.6.3") |
173 | 181 | logger.line() |
174 | 182 |
|
175 | 183 | async def load_extensions(self): |
@@ -926,32 +934,24 @@ async def process_dm_modmail(self, message: discord.Message) -> None: |
926 | 934 | logger.info("A message was blocked from %s due to disabled Modmail.", message.author) |
927 | 935 | await self.add_reaction(message, blocked_emoji) |
928 | 936 | return await message.channel.send(embed=embed) |
929 | | - for snap in message.message_snapshots: |
930 | | - author = getattr(snap, "author", None) |
931 | | - author_name = getattr(author, "name", "Unknown") if author else "Unknown" |
932 | | - author_avatar = getattr(author, "display_avatar", None) |
933 | | - author_avatar_url = author_avatar.url if author_avatar else None |
934 | | - # fix: Only use '[This is a forwarded message.]' if snap.content is actually empty |
935 | | - content = snap.content if snap.content else "[This is a forwarded message.]" |
936 | | - if snap.embeds: |
937 | | - content += "\n" + "\n".join( |
938 | | - [e.to_dict().get("description", "[embed]") for e in snap.embeds] |
939 | | - ) |
940 | | - if snap.attachments: |
941 | | - content += "\n" + "\n".join([a.url for a in snap.attachments]) |
942 | | - |
943 | | - class DummySnap: |
944 | | - def __init__(self, snap, author, content): |
945 | | - self.author = author |
946 | | - self.content = content |
947 | | - self.attachments = getattr(snap, "attachments", []) |
948 | | - self.stickers = getattr(snap, "stickers", []) |
949 | | - self.created_at = getattr(snap, "created_at", message.created_at) |
950 | | - self.embeds = getattr(snap, "embeds", []) |
951 | | - self.id = getattr(snap, "id", 0) |
952 | | - |
953 | | - dummy_msg = DummySnap(snap, author, content) |
954 | | - await thread.send(dummy_msg) |
| 937 | + # Extract forwarded content using utility function |
| 938 | + combined_content = extract_forwarded_content(message) or "[Forwarded message with no content]" |
| 939 | + |
| 940 | + class ForwardedMessage: |
| 941 | + def __init__(self, original_message, forwarded_content): |
| 942 | + self.author = original_message.author |
| 943 | + self.content = forwarded_content |
| 944 | + self.attachments = [] |
| 945 | + self.stickers = [] |
| 946 | + self.created_at = original_message.created_at |
| 947 | + self.embeds = [] |
| 948 | + self.id = original_message.id |
| 949 | + self.flags = original_message.flags |
| 950 | + self.message_snapshots = original_message.message_snapshots |
| 951 | + self.type = getattr(original_message, "type", None) |
| 952 | + |
| 953 | + forwarded_msg = ForwardedMessage(message, combined_content) |
| 954 | + await thread.send(forwarded_msg) |
955 | 955 | await self.add_reaction(message, sent_emoji) |
956 | 956 | self.dispatch("thread_reply", thread, False, message, False, False) |
957 | 957 | return |
@@ -1020,7 +1020,28 @@ def __init__(self, snap, author, content): |
1020 | 1020 | ) |
1021 | 1021 | await self.add_reaction(message, blocked_emoji) |
1022 | 1022 | return await message.channel.send(embed=embed) |
1023 | | - await thread.send(ref_msg) |
| 1023 | + |
| 1024 | + # Create a forwarded message wrapper to preserve forward info |
| 1025 | + class ForwardedMessage: |
| 1026 | + def __init__(self, original_message, ref_message): |
| 1027 | + self.author = original_message.author |
| 1028 | + # Use the utility function to extract content or fallback to ref message content |
| 1029 | + extracted_content = extract_forwarded_content(original_message) |
| 1030 | + self.content = ( |
| 1031 | + extracted_content |
| 1032 | + or ref_message.content |
| 1033 | + or "[Forwarded message with no text content]" |
| 1034 | + ) |
| 1035 | + self.attachments = getattr(ref_message, "attachments", []) |
| 1036 | + self.stickers = getattr(ref_message, "stickers", []) |
| 1037 | + self.created_at = original_message.created_at |
| 1038 | + self.embeds = getattr(ref_message, "embeds", []) |
| 1039 | + self.id = original_message.id |
| 1040 | + self.type = getattr(original_message, "type", None) |
| 1041 | + self.reference = original_message.reference |
| 1042 | + |
| 1043 | + forwarded_msg = ForwardedMessage(message, ref_msg) |
| 1044 | + await thread.send(forwarded_msg) |
1024 | 1045 | await self.add_reaction(message, sent_emoji) |
1025 | 1046 | self.dispatch("thread_reply", thread, False, message, False, False) |
1026 | 1047 | return |
@@ -1990,7 +2011,7 @@ def main(): |
1990 | 2011 | sys.exit(0) |
1991 | 2012 |
|
1992 | 2013 | # check discord version |
1993 | | - discord_version = "2.5.2" |
| 2014 | + discord_version = "2.6.3" |
1994 | 2015 | if discord.__version__ != discord_version: |
1995 | 2016 | logger.error( |
1996 | 2017 | "Dependencies are not updated, run pipenv install. discord.py version expected %s, received %s", |
|
0 commit comments