I am developing a Telegram bot using Node.js and axios to interact with the Telegram Bot API. I need to get a list of all chat names that the bot is a member of. I am able to fetch updates and chat information using the getUpdates and getChat methods. Here is my current code:
const axios = require('axios');
const botToken = process.env.BOT_TOKEN;
const apiUrl = `https://api.telegram.org/bot${'botToken'}`;
const getUpdates = async () => {
try {
const response = await axios.get(`${apiUrl}/getUpdates`);
return response.data;
} catch (err) {
console.error(err);
throw err
}
};
const getChat = async (chatId) => {
try {
const response = await axios.get(`${apiUrl}/getChat`, {
params: {
chat_id: chatId,
},
});
return response.data;
} catch (err) {
console.error(err);
throw err
}
}
module.exports = {getUpdates, getChat}
How can I get a list of all chats that the bot is a member of using the getUpdates method?
How can I extract the names of these chats?
At the moment, I am receiving updates but am not entirely sure how to properly extract chat information and its name from the data received. What is the best way to do this? Are there any potential issues or limitations when obtaining this information?
I would appreciate any help!