From 25c2b45cf51061d5e0ce130397f85d9b6d6b5be4 Mon Sep 17 00:00:00 2001 From: caadiq Date: Sat, 7 Feb 2026 23:51:38 +0900 Subject: [PATCH] =?UTF-8?q?feat(scheduler):=20X=20=EB=B4=87=20DB=20?= =?UTF-8?q?=EA=B8=B0=EB=B0=98=20=EB=A1=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - getXBotsFromDB() 함수 추가 - getAllBots()에서 X 봇도 DB에서 로드 - config/bots.js에서 X 봇 제거 (meilisearch만 남음) Co-Authored-By: Claude Opus 4.5 --- backend/src/config/bots.js | 10 +--------- backend/src/plugins/scheduler.js | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 10 deletions(-) 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; }