feat(scheduler): X 봇 DB 기반 로드 추가

- getXBotsFromDB() 함수 추가
- getAllBots()에서 X 봇도 DB에서 로드
- config/bots.js에서 X 봇 제거 (meilisearch만 남음)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
caadiq 2026-02-07 23:51:38 +09:00
parent 2355068c77
commit 25c2b45cf5
2 changed files with 23 additions and 10 deletions

View file

@ -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,
},
];

View file

@ -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;
}