|
@@ -34,28 +34,32 @@ export default class Worker {
|
|
|
const index = 0;
|
|
const index = 0;
|
|
|
|
|
|
|
|
while (true) {
|
|
while (true) {
|
|
|
- const time = Date.now();
|
|
|
|
|
- const result = await this._redisClient.zRangeByScore(key, index, time);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ const time = Date.now();
|
|
|
|
|
+ const result = await this._redisClient.zRangeByScore(key, index, time);
|
|
|
|
|
|
|
|
- if (result?.length == 0) {
|
|
|
|
|
- await this.sleep(1000);
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (result?.length == 0) {
|
|
|
|
|
+ await this.sleep(1000);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if (config.LOG_LEVEL === LogLevels.DEBUG) {
|
|
|
|
|
- console.log(`Reminders fetch ${result}`);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (config.LOG_LEVEL === LogLevels.DEBUG) {
|
|
|
|
|
+ console.log(`Reminders fetch ${result}`);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- const item = result[0];
|
|
|
|
|
- const removed = this._redisClient.zRem(key, item);
|
|
|
|
|
- if (!removed) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const data = JSON.parse(item);
|
|
|
|
|
- const status = `@${data.account} \nSe cumplió tu recordatorio ${Emojis.ALARM_CLOCK} \n${data.text}`;
|
|
|
|
|
- await this.reply(data.statusId, data.account, data.visibility, status);
|
|
|
|
|
|
|
+ const item = result[0];
|
|
|
|
|
+ const removed = this._redisClient.zRem(key, item);
|
|
|
|
|
+ if (!removed) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ const data = JSON.parse(item);
|
|
|
|
|
+ const status = `@${data.account} \nSe cumplió tu recordatorio ${Emojis.ALARM_CLOCK} \n${data.text}`;
|
|
|
|
|
+ await this.reply(data.statusId, data.account, data.visibility, status);
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error(error);
|
|
|
|
|
+ await this.sleep(1000);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|