Files
streetmerchant/src/notification/telegram.ts
T
2020-09-19 17:36:33 -04:00

21 lines
512 B
TypeScript

import {Config} from '../config';
import {Logger} from '../logger';
import {TelegramClient} from 'messaging-api-telegram';
const telegram = Config.notifications.telegram;
const client = new TelegramClient({
accessToken: telegram.accessToken
});
export function sendTelegramMessage(text: string) {
(async () => {
try {
await client.sendMessage(telegram.chatId, text);
Logger.info(`✔ telegram message sent to '${telegram.chatId}': ${text}`);
} catch (error) {
Logger.error(error);
}
})();
}