diff --git a/config.js b/config.js index f21ba24..f40f261 100644 --- a/config.js +++ b/config.js @@ -55,17 +55,17 @@ module.exports = function(rssi){ }); }, action : (bot,event,message)=>{ - return this.rssi.forEach(entry=> - db.get_v(entry.chat).then(v=> - get_rss(entry.url,v).then(articles=> - articles.forEach(art=> - db.set_v(entry.url,parseInt(art.guid)).then(rr=> - this.bot.telegram.sendMessage(entry.chat,article_to_mess(art),{"parse_mode":"Markdown"}) - ) - ) + return Promise.all(this.rssi.map(entry=> + db.get_v(entry.chat).then(v=> + get_rss(entry.url,v).then(articles=> + articles.forEach(art=> + db.set_v(entry.url,parseInt(art.guid)).then(rr=> + this.bot.telegram.sendMessage(entry.chat,article_to_mess(art),{"parse_mode":"Markdown"}) ) - ) + ) ) + ) + )) } } ], diff --git a/db.js b/db.js index 690e90b..edf7b16 100644 --- a/db.js +++ b/db.js @@ -42,16 +42,16 @@ module.exports = function(name){ this.set_v = function(cid,v){ this.get_chat(cid); - return new Promise((resolve, reject)=>{ - resolve(this.db.get("chats").find({id:cid}).set('tracking',v).write()); - }); + return new Promise((resolve, reject)=> + resolve(this.db.get("chats").find({id:cid}).set('tracking',v).write()) + ); }; this.get_v = function(cid){ this.get_chat(cid); - return new Promise((resolve, reject)=>{ - resolve(this.db.get("chats").find({id:cid}).get('tracking').value()); - }); + return new Promise((resolve, reject)=> + resolve(this.db.get("chats").find({id:cid}).get('tracking').value()) + ); } return this; diff --git a/manual.js b/manual.js index 671b99d..23df532 100644 --- a/manual.js +++ b/manual.js @@ -37,7 +37,8 @@ const get_rss = function(url,min_id){ .sort((a, b)=>(parseInt(a.guid)-parseInt(b.guid))) .filter((v)=>(parseInt(v.guid)>min_id))); } +console.log(get_url({org:ORG.BR, lang:'de',since:-2})) + get_rss(get_url({org:ORG.BR, lang:'de',since:-2}),79710).then(r=>r.forEach(item=>{ - console.log(item) - //console.log(`${item.title} (${item.guid}): ${item.link}`); + console.log(`${item.title} (${item.guid}): ${item.link}`); }));