diff --git a/.env b/.env index e289375..650885b 100644 --- a/.env +++ b/.env @@ -6,6 +6,9 @@ DISCORD_TOKEN=MTQ5MTAxODYzOTc0MTI5MjY0NA.GxBqVk.dB3cWx8t8-kWLrMLGFL-g2ePkrs7l_XE # Right-click a channel and select "Copy Channel ID" (enable Developer Mode first) DISCORD_CHANNEL_IDS=600347996080701506,720537868996444230,1480636166150816007 +# Channel name mapping (channel_id=name, comma-separated) +CHANNEL_NAMES=600347996080701506=noticias,720537868996444230=eventos,1480636166150816007=changelog + # Server port (optional, defaults to 3000) PORT=8000 diff --git a/data/messages.db b/data/messages.db index 8a16843..7946588 100644 Binary files a/data/messages.db and b/data/messages.db differ diff --git a/src/rss.js b/src/rss.js index 2cf96d5..056e291 100644 --- a/src/rss.js +++ b/src/rss.js @@ -4,10 +4,44 @@ import { getMessagesByChannel, getAllChannels, getAllMessages } from './database const router = express.Router(); +// Channel emoji badges (add more as needed) +const CHANNEL_EMOJIS = { + 'noticias': '📢', + 'eventos': '📅', + 'changelog': '🔄', + 'general': '💬', + 'announcements': '📣', +}; + +// Parse channel names from environment variable +function getChannelNames() { + const namesStr = process.env.CHANNEL_NAMES || ''; + const names = {}; + if (namesStr) { + namesStr.split(',').forEach(pair => { + const [id, name] = pair.split('='); + if (id && name) { + names[id.trim()] = name.trim(); + } + }); + } + return names; +} + +function getChannelDisplayName(channelId) { + const names = getChannelNames(); + return names[channelId] || channelId; +} + +function getChannelEmoji(channelName) { + return CHANNEL_EMOJIS[channelName.toLowerCase()] || '📄'; +} + function generateRSSFeed(messages, channelInfo, feedUrlSuffix = null) { + const isCombined = channelInfo === 'All Channels'; const feed = new RSS({ - title: `Discord Channel - ${channelInfo}`, - description: 'Messages from Discord channel', + title: `Discord - ${channelInfo}`, + description: isCombined ? 'Latest messages from all channels' : `Messages from ${channelInfo}`, feed_url: `${process.env.BASE_URL || 'http://localhost:3000'}/rss/${feedUrlSuffix || channelInfo}`, site_url: process.env.BASE_URL || 'http://localhost:3000', language: 'en', @@ -17,9 +51,28 @@ function generateRSSFeed(messages, channelInfo, feedUrlSuffix = null) { for (const msg of messages) { const pubDate = new Date(msg.created_at); + const channelName = getChannelDisplayName(msg.channel_id); + const emoji = getChannelEmoji(channelName); + + // HTML-formatted description with visual badge + const formattedDescription = ` +