fix role mentions in stoat
This commit is contained in:
parent
518438cb09
commit
806966450b
4 changed files with 10 additions and 14 deletions
|
|
@ -390,7 +390,7 @@ async def migrate_messages(
|
||||||
# Use custom clean_mentions with msg mentions for accuracy
|
# Use custom clean_mentions with msg mentions for accuracy
|
||||||
content = clean_mentions(
|
content = clean_mentions(
|
||||||
msg.content,
|
msg.content,
|
||||||
msg.guild,
|
context.discord_reader.guild,
|
||||||
msg.mentions,
|
msg.mentions,
|
||||||
msg.role_mentions,
|
msg.role_mentions,
|
||||||
msg.channel_mentions,
|
msg.channel_mentions,
|
||||||
|
|
@ -422,10 +422,10 @@ async def migrate_messages(
|
||||||
snapshot = msg.message_snapshots[0]
|
snapshot = msg.message_snapshots[0]
|
||||||
if not content: # Only update content if it wasn't already set (e.g., by thread_starter_message)
|
if not content: # Only update content if it wasn't already set (e.g., by thread_starter_message)
|
||||||
content = snapshot.content
|
content = snapshot.content
|
||||||
if hasattr(msg, 'guild') and msg.guild:
|
if context.discord_reader.guild:
|
||||||
content = clean_mentions(
|
content = clean_mentions(
|
||||||
content,
|
content,
|
||||||
msg.guild,
|
context.discord_reader.guild,
|
||||||
snapshot.mentions if hasattr(snapshot, 'mentions') else None,
|
snapshot.mentions if hasattr(snapshot, 'mentions') else None,
|
||||||
snapshot.role_mentions if hasattr(snapshot, 'role_mentions') else None,
|
snapshot.role_mentions if hasattr(snapshot, 'role_mentions') else None,
|
||||||
snapshot.channel_mentions if hasattr(snapshot, 'channel_mentions') else None, # Changed this line
|
snapshot.channel_mentions if hasattr(snapshot, 'channel_mentions') else None, # Changed this line
|
||||||
|
|
|
||||||
|
|
@ -285,7 +285,7 @@ class FluxerWriter:
|
||||||
# -# is Fluxer/Discord's subtext markdown: small, muted grey text
|
# -# is Fluxer/Discord's subtext markdown: small, muted grey text
|
||||||
prefix = f"-# <t:{timestamp}:D>\n"
|
prefix = f"-# <t:{timestamp}:D>\n"
|
||||||
if is_forwarded:
|
if is_forwarded:
|
||||||
prefix += "-# ⤷*forwarded*\n"
|
prefix += "-# ⮫*forwarded*\n"
|
||||||
|
|
||||||
display_content = content
|
display_content = content
|
||||||
if is_forwarded and content:
|
if is_forwarded and content:
|
||||||
|
|
@ -345,7 +345,7 @@ class FluxerWriter:
|
||||||
# We add the author name to the prefix since bot name won't match
|
# We add the author name to the prefix since bot name won't match
|
||||||
bot_prefix = f"-# <t:{timestamp}:D>\n"
|
bot_prefix = f"-# <t:{timestamp}:D>\n"
|
||||||
if is_forwarded:
|
if is_forwarded:
|
||||||
bot_prefix += "-# ⤷*forwarded*\n"
|
bot_prefix += "-# ⮫*forwarded*\n"
|
||||||
bot_prefix += f"-# · {author_name}\n"
|
bot_prefix += f"-# · {author_name}\n"
|
||||||
|
|
||||||
final_bot_content = bot_prefix + display_content if display_content else bot_prefix
|
final_bot_content = bot_prefix + display_content if display_content else bot_prefix
|
||||||
|
|
|
||||||
|
|
@ -46,11 +46,7 @@ def clean_mentions(content: str, guild, user_mentions=None, role_mentions=None,
|
||||||
|
|
||||||
def replace_role(match):
|
def replace_role(match):
|
||||||
rid = int(match.group(1))
|
rid = int(match.group(1))
|
||||||
# 0. Try native mapping first
|
# Stoat does not support migrating Discord Role mentions natively, always use the name as fallback
|
||||||
if state:
|
|
||||||
target_role_id = state.get_target_role_id(str(rid))
|
|
||||||
if target_role_id:
|
|
||||||
return f"<@&{target_role_id}>"
|
|
||||||
|
|
||||||
# 1. Try provided guild cache/list
|
# 1. Try provided guild cache/list
|
||||||
role = guild.get_role(rid) or next((r for r in guild.roles if r.id == rid), None)
|
role = guild.get_role(rid) or next((r for r in guild.roles if r.id == rid), None)
|
||||||
|
|
@ -393,7 +389,7 @@ async def migrate_messages(
|
||||||
# Use custom clean_mentions with msg mentions for accuracy
|
# Use custom clean_mentions with msg mentions for accuracy
|
||||||
content = clean_mentions(
|
content = clean_mentions(
|
||||||
msg.content,
|
msg.content,
|
||||||
msg.guild,
|
context.discord_reader.guild,
|
||||||
msg.mentions,
|
msg.mentions,
|
||||||
msg.role_mentions,
|
msg.role_mentions,
|
||||||
msg.channel_mentions,
|
msg.channel_mentions,
|
||||||
|
|
@ -421,10 +417,10 @@ async def migrate_messages(
|
||||||
snapshot = msg.message_snapshots[0]
|
snapshot = msg.message_snapshots[0]
|
||||||
if not content:
|
if not content:
|
||||||
content = snapshot.content
|
content = snapshot.content
|
||||||
if hasattr(msg, 'guild') and msg.guild:
|
if context.discord_reader.guild:
|
||||||
content = clean_mentions(
|
content = clean_mentions(
|
||||||
content,
|
content,
|
||||||
msg.guild,
|
context.discord_reader.guild,
|
||||||
snapshot.mentions if hasattr(snapshot, 'mentions') else None,
|
snapshot.mentions if hasattr(snapshot, 'mentions') else None,
|
||||||
snapshot.role_mentions if hasattr(snapshot, 'role_mentions') else None,
|
snapshot.role_mentions if hasattr(snapshot, 'role_mentions') else None,
|
||||||
snapshot.channel_mentions if hasattr(snapshot, 'channel_mentions') else None,
|
snapshot.channel_mentions if hasattr(snapshot, 'channel_mentions') else None,
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,7 @@ class StoatWriter:
|
||||||
# Build content with timestamp prefix
|
# Build content with timestamp prefix
|
||||||
prefix = f"###### <t:{timestamp}:D>\n"
|
prefix = f"###### <t:{timestamp}:D>\n"
|
||||||
if is_forwarded:
|
if is_forwarded:
|
||||||
prefix += "##### ⤷*forwarded*\n"
|
prefix += "##### ⮫*forwarded*\n"
|
||||||
|
|
||||||
display_content = content
|
display_content = content
|
||||||
if is_forwarded and content:
|
if is_forwarded and content:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue