forked from AleG94/Pricegram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
24 lines (19 loc) · 742 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
'use strict';
const config = require('config');
const logger = require('./lib/logger')();
const database = require('./lib/database');
const Bot = require('./lib/bot');
const priceTracker = require('./lib/price-tracker');
const Alert = require('./lib/templates/alert');
const mongoConnectionURI = config.get('mongo.connectionURI');
const telegramBotToken = config.get('telegram.token');
const bot = new Bot(telegramBotToken);
database.connect(mongoConnectionURI).then(() => {
bot.launch();
priceTracker.start();
priceTracker.on('update', product => {
bot.sendMessage(product.user, new Alert(product).toMarkdown());
logger.info(`Alert sent: ${product.name} (${product.id})`);
});
logger.info('Pricegram started...');
});