Created
April 23, 2021 08:56
-
-
Save trungx/88a68e22cebe62fd080b65acf40efda2 to your computer and use it in GitHub Desktop.
code rẻ tiền
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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