This commit is contained in:
Cedric Hoelzl 2020-07-02 20:45:33 +02:00
parent b200426c10
commit d46249d1de
3 changed files with 18 additions and 17 deletions

View File

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

12
db.js
View File

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

View File

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