From b162233265ed2f41a73ca31f0c52c23d6fea7dcb Mon Sep 17 00:00:00 2001 From: Rodrigo Almeida <60528838+Rodrig0Almeida@users.noreply.github.com> Date: Tue, 2 May 2023 23:45:32 -0300 Subject: [PATCH] Update server.js when the bot starts it sends a telegram message to the user --- server.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server.js b/server.js index 715f123d..ccd38df2 100755 --- a/server.js +++ b/server.js @@ -36,6 +36,18 @@ bot.on("updateError", function (err) { bot.on("synced", function () { console.log("Bot ready."); + const axios = require('axios'); + const message = 'the Bot started'; + const chatId = config.owner; + const apiUrl = `https://api.telegram.org/bot${config.authToken}`; + axios.post(`${apiUrl}/sendMessage`, { + chat_id: chatId, + text: message +}).then(response => { + console.log('Message sent:', response.data.result.text); +}).catch(error => { + console.error('Error sending message:', error.response.data.description); +}); });