This commit is contained in:
Cedric Hoelzl 2020-07-03 11:56:46 +02:00
parent 9752ebd8d9
commit e093970987
2 changed files with 9 additions and 5 deletions

View File

@ -63,7 +63,7 @@ module.exports = function(rssi){
Promise.all(articles.map(art=>
this.bot.telegram.sendMessage(entry.chat,article_to_mess(art),{"parse_mode":"Markdown"})
)).then(rr=>
(articles.length == 0) || db.set_v(entry.chat,parseInt(articles.shift().guid))
(articles.length == 0) || db.set_v(entry.chat,parseInt(articles.pop().guid))
)
)
)
@ -98,7 +98,7 @@ module.exports = function(rssi){
Promise.all(articles.map(art=>
this.bot.telegram.sendMessage(entry.chat,article_to_mess(art),{"parse_mode":"Markdown"})
)).then(rr=>
(articles.length == 0) || db.set_v(entry.chat,parseInt(articles.shift().guid))
(articles.length == 0) || db.set_v(entry.chat,parseInt(articles.pop().guid))
)
)
)

View File

@ -35,10 +35,14 @@ const get_url = function(opts){
const get_rss = function(url,min_id){
return parser.parseURL(url).then(feed=>feed.items).then(items=>{
let idx = items.findIndex(i => parseInt(i.guid) === min_id);
console.log(idx);
if(idx>=0) return items.slice(0,idx).reverse();
else return items.reverse();
});
}
get_rss(get_url({org:ORG.BR, lang:'de',since:-3}),79718).then(r=>r.forEach(item=>{
console.log(`${item.title} (${item.guid}): ${item.link}`);
}));
get_rss(get_url({org:ORG.BR, lang:'de',since:-3}),79718).then(r=>{
r.forEach(item=>{
console.log(`${item.title} (${item.guid}): ${item.link}`);
})
console.log(r.pop());
})