support file attachments via webhook

This commit is contained in:
rambros 2026-02-24 17:09:53 +05:30
parent bfdd7b3411
commit f078fe2cf5
3 changed files with 16 additions and 14 deletions

View file

@ -1,5 +1,6 @@
git+https://github.com/akarealemil/fluxer.py.git
discord.py>=2.3.2
rich>=13.7.0
PyYAML>=6.0.1
pydantic>=2.5.3 # Good for configuration validation and mapping
git+https://github.com/rambros3d/fluxer.py.git # API wrapper for Fluxer
discord.py # API wrapper for Discord
rich # Terminal formatting and rich text
PyYAML # YAML parsing and serialization
pydantic # Data validation using Python type hints

View file

@ -5,7 +5,7 @@ logger = logging.getLogger(__name__)
async def log_audit_event(context: MigrationContext, title: str, description: str, files: list[dict] | None = None) -> None:
"""
Logs an event by sending a summary to the `#fluxer-reaper` audit channel.
Logs an event by sending a summary to the `#reaper-logs` audit channel.
If the channel does not exist, it will dynamically create it and hide it from @everyone.
"""
# 1. Initialize or Validate channel
@ -31,16 +31,16 @@ async def log_audit_event(context: MigrationContext, title: str, description: st
for ch in channels:
name = str(ch.get("name", "")).lower()
if name in ["fluxer-reaper", "fluxer_reaper"]:
if name in ["reaper-logs", "reaper_logs"]:
channel_id = str(ch.get("id"))
logger.info(f"Found existing audit channel: {channel_id}")
break
if not channel_id:
logger.info("Audit log channel not found. Creating #fluxer-reaper.")
logger.info("Audit log channel not found. Creating #reaper-logs.")
# Create channel
channel_id = await context.fluxer_writer.create_channel(
name="fluxer-reaper",
name="reaper-logs",
topic="Fluxer Reaper - Migration audit logs.",
type=0
)

View file

@ -241,13 +241,14 @@ class FluxerWriter:
final_content = prefix + display_content if display_content else prefix
try:
# Current limitation: fluxer.py execute_webhook doesn't support 'files' or 'message_reference' yet.
# So if we have files OR a reply, we MUST use the bot's direct send method.
if webhook and not files and not reply_to_message_id:
# Current limitation: fluxer.py execute_webhook doesn't support 'message_reference' yet.
# So if we have a reply, we MUST use the bot's direct send method.
if webhook and not reply_to_message_id:
msg = await webhook.send(
content=final_content,
username=f"{author_name} (discord)",
avatar_url=author_avatar_url,
files=files,
wait=True
)
return str(msg.id) if msg else None
@ -437,7 +438,7 @@ class FluxerWriter:
sorted_channels = sorted(channels, key=lambda c: 0 if c.get("type") == 4 else -1)
for ch in sorted_channels:
name = str(ch.get("name", "")).lower()
if name in ["fluxer-reaper", "fluxer_reaper"]:
if name in ["reaper-logs", "reaper_logs"]:
logger.info(f"Danger Zone: Skipping deletion of audit channel {name}")
total -= 1
continue
@ -462,7 +463,7 @@ class FluxerWriter:
processed = 0
for ch in channels:
name = str(ch.get("name", "")).lower()
if name in ["fluxer-reaper", "fluxer_reaper"]:
if name in ["reaper-logs", "reaper_logs"]:
logger.info(f"Danger Zone: Skipping permission reset for audit channel {name}")
total -= 1
continue