newv
This commit is contained in:
parent
b200426c10
commit
d46249d1de
18
config.js
18
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"})
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
))
|
||||
}
|
||||
}
|
||||
],
|
||||
|
12
db.js
12
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;
|
||||
|
@ -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}`);
|
||||
}));
|
||||
|
Loading…
x
Reference in New Issue
Block a user