Add checking is something changed
This commit is contained in:
parent
517c5d5ff8
commit
6e1f811a8f
@ -26,6 +26,17 @@ class DisplayWorker {
|
||||
this.footer = footer;
|
||||
}
|
||||
|
||||
isSomethingChanged() {
|
||||
for (let from in this.data) {
|
||||
for (let dat of this.data[from]) {
|
||||
if(dat.change!==0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
build() {
|
||||
var sortable = [];
|
||||
|
||||
|
9
index.js
9
index.js
@ -13,10 +13,7 @@ let exchangeClient = new HilSu.ExchangeClient(process.env.HILTOKEN);
|
||||
let bot = new Telegraf(process.env.BOTTOKEN);
|
||||
|
||||
exchangeClient.on("ratesUpdate", (rates, oldRates) => {
|
||||
if (oldRates === undefined
|
||||
|| (oldRates.maxExchange.gems === rates.maxExchange.gems
|
||||
&& oldRates.maxExchange.money === rates.maxExchange.money
|
||||
&& oldRates.maxExchange.balance === rates.maxExchange.balance))
|
||||
if (oldRates === undefined)
|
||||
return;
|
||||
|
||||
handleChange(rates, oldRates)
|
||||
@ -40,7 +37,9 @@ function handleChange(rates, oldRates) {
|
||||
`Пул валют:\n Червонцы: ${rates.maxExchange.balance.toFixed(3)}\n Салоцветы: ${rates.maxExchange.gems.toFixed(3)}\n Самородки: ${rates.maxExchange.money.toFixed(3)}`
|
||||
)
|
||||
|
||||
bot.telegram.sendMessage("-765759105", message.build());
|
||||
if(message.isSomethingChanged()) {
|
||||
bot.telegram.sendMessage("-765759105", message.build());
|
||||
}
|
||||
}
|
||||
|
||||
bot.startPolling();
|
||||
|
Reference in New Issue
Block a user