M3: frontend/Dockerfile now copies package-lock.json and uses npm ci instead of npm install, for reproducible builds. M4: replace em dash with plain hyphen in manual_share.py's attachment-only fallback text (standing style preference; ping.py title and TriageList.vue's sender fallback were already fixed in prior commits). M5: Caddyfile.snippet uses basic_auth instead of the deprecated basicauth directive alias (Caddy 2.8+). M1/M2/M6 (unused discord import removal, None-payload guard in _extract_body, discord.NotFound guard in thread_ingest.py) were already included in the preceding two commits since they touched the same files.
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
import discord
|
|
from discord.ext import commands
|
|
from chorus_bot.modality_map import modality_for_channel
|
|
from chorus_bot.ping import build_ping_embed
|
|
|
|
|
|
class ManualShareCog(commands.Cog):
|
|
"""Watches per-modality channels; forwards any new message as a ping in #inbox."""
|
|
|
|
def __init__(self, bot: commands.Bot, config):
|
|
self.bot = bot
|
|
self.config = config
|
|
|
|
@commands.Cog.listener()
|
|
async def on_message(self, message: discord.Message):
|
|
if message.author.bot:
|
|
return
|
|
if message.channel.id == self.config.inbox_channel_id:
|
|
return # inbox itself is not a source channel
|
|
|
|
modality = modality_for_channel(message.channel.name)
|
|
if modality is None:
|
|
return
|
|
|
|
raw_content = message.content
|
|
display_content = message.content or "(attachment only - see original message)"
|
|
snippet = display_content if len(display_content) <= 120 else display_content[:117] + "..."
|
|
|
|
embed = build_ping_embed(
|
|
modality=modality,
|
|
sender_id=None,
|
|
snippet=snippet,
|
|
raw_content=raw_content,
|
|
captured_at=message.created_at,
|
|
)
|
|
|
|
inbox = self.bot.get_channel(self.config.inbox_channel_id)
|
|
role_mention = f"<@&{self.config.triage_role_id}>"
|
|
await inbox.send(content=role_mention, embed=embed)
|
|
|
|
|
|
async def setup(bot: commands.Bot, config):
|
|
await bot.add_cog(ManualShareCog(bot, config))
|