only send log.tele to telegram if enabled

This commit is contained in:
Karl0ss 2022-10-25 16:15:53 +01:00
parent 69460fe659
commit 949b1c668c
2 changed files with 5 additions and 15 deletions

View File

@ -52,7 +52,7 @@ async function filterFeed() {
log.info(urlObj.fileName + ' already downloaded, skipped.')
break
} else {
log.info(download_list.length + ' links for ' + urlObj.fileName + ' have been sent to JDdownloader.')
log.tele(download_list.length + ' links for ' + urlObj.fileName + ' have been sent to JDdownloader.')
linkAdder(download_list)
}
} else {

View File

@ -29,7 +29,7 @@ global.log = require('simple-node-logger').createSimpleLogger({
timestampFormat: 'YYYY-MM-DD HH:mm:ss.SSS'
});
log.info = function() {
log.tele = function() {
var args = Array.prototype.slice.call( arguments ),
entry = log.log('info', args);
process.nextTick(function() {
@ -39,16 +39,6 @@ log.info = function() {
});
};
log.error = function() {
var args = Array.prototype.slice.call( arguments ),
entry = log.log('error', args);
process.nextTick(function() {
if (config.TelegramBot) {
telegrambot(entry.msg[0])
}
});
};
app.get("/", (req, res) => {
showListLength = JSON.parse(fs.readFileSync('config.json')).Shows.length
res.render("index", { title: "Home", showListLength:showListLength, version:version });
@ -92,15 +82,15 @@ app.post('/removeShow', (req, res) => {
});
async function main() {
log.info('Running JDRssDownloader version ' + version)
log.tele('Running JDRssDownloader version ' + version)
try {
RSSFeedRefreshMins = JSON.parse(fs.readFileSync('config.json')).RSSFeedRefreshMins
JDPostLinksMins = JSON.parse(fs.readFileSync('config.json')).JDPostLinksMins
} catch (error) {
log.error('config.json file is missing.')
}
log.info('Refreshing RSS Items every ' + RSSFeedRefreshMins + ' Minutes')
log.info('Checking for links and sending to JDdownloader every ' + JDPostLinksMins + ' Minutes')
log.tele('Refreshing RSS Items every ' + RSSFeedRefreshMins + ' Minutes')
log.tele('Checking for links and sending to JDdownloader every ' + JDPostLinksMins + ' Minutes')
app.listen(port, () => log.info(`WebUi is listening on ${port}!`))
setInterval(await feedUpdater, RSSFeedRefreshMins * 60000);
setInterval(await filterFeed, JDPostLinksMins * 60000);