Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fixed and added catch
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-dubinin committed Dec 30, 2022
1 parent 71b3862 commit 9511142
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { validatorBalanceReducedAlert, validatorStatusChangedAlert } from './ale
import { logger } from './logger.js';

const notifiers = [];
if (config.sms) notifiers.push(new SMSNotifier(config.sms));
if (config.telegram) notifiers.push(new TelegramNotifier(config.telegram));
if (config.sms.accountSid) notifiers.push(new SMSNotifier(config.sms));
if (config.telegram.chatID) notifiers.push(new TelegramNotifier(config.telegram));

if (notifiers.length === 0) {
throw new Error('Missing notifier config, check your .env file!');
Expand Down
6 changes: 4 additions & 2 deletions src/notifiers/telegram-notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import {TelegramBotApiClient} from '../telegram-bot-api-client.js';
class TelegramNotifier {
constructor(config) {
this.chatID = config.chatID;
this.client = new TelegramBotApiClient(config.telegram.botURL, config.telegram.botToken);
this.client = new TelegramBotApiClient(config.botURL, config.botToken);
}

notify(message) {
logger.info(`Sending telegram message to chat_id[${this.chatID}] via bot: ${message}`);
this.client.sendMessage(this.chatID, message).then(r => logger.info("Message sent to " + this.chatID));
this.client.sendMessage(this.chatID, message)
.then(r => logger.info("Message sent to " + this.chatID))
.catch(err => logger.error('Error sending a message', err));
}

}
Expand Down

0 comments on commit 9511142

Please sign in to comment.