hometify/server/services/telegram/telegramBot.js

22 lines
575 B
JavaScript

import TelegramBot from 'node-telegram-bot-api';
import Listing from '../../server/db/models/Listing';
const botToken = process.env.TELEGRAM_BOT_TOKEN;
const chatId = process.env.TELEGRAM_CHAT_ID;
const bot = new TelegramBot(botToken, { polling: true });
export const notifyNewListing = async (listing) => {
const message = `
New Listing:
Title: ${listing.title}
Price: ${listing.price}
Location: ${listing.location}
Description: ${listing.description}
URL: ${listing.url}
`;
await bot.sendMessage(chatId, message);
};
export default bot;