Skip to content

Instantly share code, notes, and snippets.

@trungx
Created April 23, 2021 08:56
Show Gist options
  • Save trungx/88a68e22cebe62fd080b65acf40efda2 to your computer and use it in GitHub Desktop.
Save trungx/88a68e22cebe62fd080b65acf40efda2 to your computer and use it in GitHub Desktop.
code rẻ tiền
function comparer(otherArray) {
return function(current){
return otherArray.filter(function(other){
return other.id == current.id && other.symbol == current.symbol && other.name == current.name
}).length == 0;
}
}
let origirnalList = [];
setInterval(()=> {
axios.get('https://api.coingecko.com/api/v3/coins/list')
.then((response) => {
let newList = response.data;
if (origirnalList.length) {
let diffNewOnOrigirnalList = newList.filter(comparer(origirnalList));
if (diffNewOnOrigirnalList.length > 0) {
diffNewOnOrigirnalList.forEach(item => {
bot.sendMessage(chanelId, JSON.stringify(item));
});
}
}
origirnalList = newList;
});
}, 5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment