diff --git a/backend/src/config/bots.js b/backend/src/config/bots.js index 0167e69..515e11d 100644 --- a/backend/src/config/bots.js +++ b/backend/src/config/bots.js @@ -1,4 +1,4 @@ -// 정적 봇 설정 (YouTube 봇은 DB에서 관리) +// 정적 봇 설정 (YouTube, X 봇은 DB에서 관리) export default [ { id: 'meilisearch-sync', @@ -7,12 +7,4 @@ export default [ cron: '0 0 * * *', // 매일 00시 전체 동기화 enabled: true, }, - { - id: 'x-fromis9', - type: 'x', - username: 'realfromis_9', - nitterUrl: process.env.NITTER_URL || 'http://nitter:8080', - cron: '*/1 * * * *', - enabled: true, - }, ]; diff --git a/backend/src/plugins/scheduler.js b/backend/src/plugins/scheduler.js index 69ceece..811fbdc 100644 --- a/backend/src/plugins/scheduler.js +++ b/backend/src/plugins/scheduler.js @@ -47,6 +47,26 @@ async function schedulerPlugin(fastify, opts) { })); } + /** + * DB에서 X 봇 목록 조회 + */ + async function getXBotsFromDB() { + const [rows] = await fastify.db.query( + 'SELECT * FROM bot_x WHERE enabled = 1' + ); + return rows.map(row => ({ + id: `x-${row.id}`, + dbId: row.id, + type: 'x', + username: row.username, + displayName: row.display_name, + avatarUrl: row.avatar_url, + nitterUrl: process.env.NITTER_URL || 'http://nitter:8080', + cron: `*/${row.cron_interval} * * * *`, + enabled: row.enabled === 1, + })); + } + /** * 모든 봇 목록 가져오기 (정적 + DB) */ @@ -55,7 +75,8 @@ async function schedulerPlugin(fastify, opts) { return cachedBots; } const youtubeBots = await getYouTubeBotsFromDB(); - cachedBots = [...staticBots, ...youtubeBots]; + const xBots = await getXBotsFromDB(); + cachedBots = [...staticBots, ...youtubeBots, ...xBots]; return cachedBots; }