-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (22 loc) · 975 Bytes
/
index.js
File metadata and controls
29 lines (22 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require('dotenv').config();
const { GoogleGenerativeAI } = require('@google/generative-ai');
const { loadConfig } = require('./src/config');
const { createClient, handleMessage } = require('./src/bot');
const { getClient: getSheetsClient, initSheets } = require('./src/sheets');
const { startHealthServer } = require('./src/health');
const { createTransport } = require('./src/mailer');
async function main() {
const config = loadConfig();
const genAI = new GoogleGenerativeAI(config.geminiApiKey);
const sheetsClient = getSheetsClient(config.serviceAccountKeyPath);
const transport = createTransport(config);
startHealthServer(config.healthPort);
await initSheets(sheetsClient, config.sheetsId);
const client = createClient(config, transport);
client.on('message_create', msg => handleMessage(msg, config, genAI, sheetsClient));
await client.initialize();
}
main().catch(err => {
console.error('Fatal startup error:', err);
process.exit(1);
});