fixing order
This commit is contained in:
parent
0411a48371
commit
cfb9d7fd35
28
config.js
28
config.js
@ -13,9 +13,11 @@ var db = new db_js("rss_chan");
|
|||||||
//=== TOOL FUNCTIONS
|
//=== TOOL FUNCTIONS
|
||||||
|
|
||||||
const get_rss = function(url,min_id){
|
const get_rss = function(url,min_id){
|
||||||
return parser.parseURL(url).then(feed=>feed.items
|
return parser.parseURL(url).then(feed=>{
|
||||||
.sort((a, b)=>(parseInt(a.guid)-parseInt(b.guid)))
|
let idx = feed.findIndex(i => i.prop_1 === min_id);
|
||||||
.filter((v)=>(parseInt(v.guid)>min_id)));
|
if(idx>=0) return feed.items.slice(0,idx);
|
||||||
|
else return feed.items;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const article_to_mess = function(art){
|
const article_to_mess = function(art){
|
||||||
@ -58,11 +60,11 @@ module.exports = function(rssi){
|
|||||||
return Promise.all(this.rssi.map(entry=>
|
return Promise.all(this.rssi.map(entry=>
|
||||||
db.get_v(entry.chat).then(v=>
|
db.get_v(entry.chat).then(v=>
|
||||||
get_rss(entry.url,v).then(articles=>
|
get_rss(entry.url,v).then(articles=>
|
||||||
articles.forEach(art=>
|
Promise.all(articles.map(art=>
|
||||||
db.set_v(entry.chat,parseInt(art.guid)).then(rr=>
|
this.bot.telegram.sendMessage(entry.chat,article_to_mess(art),{"parse_mode":"Markdown"})
|
||||||
this.bot.telegram.sendMessage(entry.chat,article_to_mess(art),{"parse_mode":"Markdown"})
|
)).then(rr=>
|
||||||
)
|
db.set_v(entry.chat,parseInt(articles.pop().guid))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)).then(r=>event.reply("Refreshed all Feeds"));
|
)).then(r=>event.reply("Refreshed all Feeds"));
|
||||||
@ -93,11 +95,11 @@ module.exports = function(rssi){
|
|||||||
return Promise.all(this.rssi.map(entry=>
|
return Promise.all(this.rssi.map(entry=>
|
||||||
db.get_v(entry.chat).then(v=>
|
db.get_v(entry.chat).then(v=>
|
||||||
get_rss(entry.url,v).then(articles=>
|
get_rss(entry.url,v).then(articles=>
|
||||||
articles.forEach(art=>
|
Promise.all(articles.map(art=>
|
||||||
db.set_v(entry.chat,parseInt(art.guid)).then(rr=>
|
this.bot.telegram.sendMessage(entry.chat,article_to_mess(art),{"parse_mode":"Markdown"})
|
||||||
this.bot.telegram.sendMessage(entry.chat,article_to_mess(art),{"parse_mode":"Markdown"})
|
)).then(rr=>
|
||||||
)
|
db.set_v(entry.chat,parseInt(articles.pop().guid))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user