Questions tagged [node-telegram-bot-api]

Node.js Telegram Bot API Node.js module to interact with official Telegram Bot API.

Node.js module to interact with official Telegram Bot API. A bot token is required and can be obtained by talking to @botfather.

Install

npm install --save node-telegram-bot-api

Usage

const TelegramBot = require('node-telegram-bot-api');

// replace the value below with the Telegram token you receive from @BotFather
const token = 'YOUR_TELEGRAM_BOT_TOKEN';

// Create a bot that uses 'polling' to fetch new updates
const bot = new TelegramBot(token, {polling: true});

// Matches "/echo [whatever]"
bot.onText(/\/echo (.+)/, (msg, match) => {
  // 'msg' is the received Message from Telegram
  // 'match' is the result of executing the regexp above on the text content
  // of the message

  const chatId = msg.chat.id;
  const resp = match[1]; // the captured "whatever"

  // send back the matched "whatever" to the chat
  bot.sendMessage(chatId, resp);
});

// Listen for any kind of message. There are different kinds of
// messages.
bot.on('message', (msg) => {
  const chatId = msg.chat.id;

  // send a message to the chat acknowledging receipt of their message
  bot.sendMessage(chatId, 'Received your message');
});
159 questions
0
votes
0 answers

How do you make a stream buffer using node youtube-dl-exec wrapper?

I want to have function like this, where I take youtube shorts link, download the video into some buffer and return it as a result. const handleYoutubeLink = async (url) => { if (!url.includes('youtube')) return null let buffer = await…
Bohdan
  • 53
  • 5
0
votes
0 answers

Telegram Bot Conflict Error: Multiple Instances Running - Node.js

I am using node-telegram-bot-api NPM when I run the app.js file on my pc it does not give any error. But when I use render.com render to deploy my project it throws an error. Render error The app is running and it send messages but I also use…
0
votes
1 answer

Is it possible to copy the text from a protected message sent by a Telegram bot?

I am using the sendMessage() function with protected_content: true because I don't want Telegram users to forward my bot's message to the others. Originally the text below was copyable, but after I set protected_content=true, users couldn't copy the…
0
votes
0 answers

Is it posible to know how many users and which ones have been join my telegram group using a certain invite link in a programmatic way?

I want to know exactly which users have being invite (and join my group) by each of my invite links. It is important to me in order to make statistics and to give perks to the people that is getting me new followers (by referal system). I have check…
0
votes
0 answers

How to share contact with telegram bot to reply message on IOS?

I am writng telegram bot on nodejs with node-telegram-bot-api. For authorization i use reply keyboard with request_contact param. request_contact keyboard. When the user clicks on button "Поделиться контактом" (Share contact), on desktop version,…
0
votes
1 answer

telegram photo download file path (node,js)

I need my bot to save photos to my computer, where it is running, to a specified path. The function for this: const fs = require('fs'); const path = require('path'); ... bot.on('photo', (msg) => { const chatId = msg.chat.id; const photo =…
0
votes
0 answers

Cant understand why doesnt my telegram bot delete message

Made bot with node-telegram-bot-api. My bot has next function, that reacts to some word and with some chance sends a picture as reply, it must delete this message with picture in several seconds, but it doesnt. Cant understand why doesnt bot delete…
Rubyroido
  • 1
  • 1
0
votes
2 answers

Force change scene of another user in Telegraf.js

I am creating game bot, where user should answer some questions, and admin should approve or reject them. I need to find a way, when admin is accepted the answer, to force change scene of the user. So for example the user is in scene "answering".…
0
votes
1 answer

Telegram get a list of all the groups i have admin privileges in

i am finding it difficult figuring out all the groups that i have admin privileges in so that i can add my bot. there are about 300 groups. is there any user level api or a 3rd party api to achieve this?
Spidy
  • 556
  • 5
  • 11
0
votes
1 answer

Telegram message relay bot

Good afternoon. I am writing a telegram bot using node-telegram-bot-api and sequelize. One of the tasks that the bot faces is to automatically forward or copy messages from one channel to another. In both channels, the bot is assigned as an…
0
votes
1 answer

Encountering an elusive error with Telegram API in AWS Lambda function

For some context, I am writing a Telegram bot using NodeJS (node-telegram-bot-api) and AWS Lambda functions to handle requests from users and respond. We are using an API gateway and a webhook to hit an initial lambda function, which has some logic…
0
votes
0 answers

Telegram Login Widget session status check with Bot API?

I'm using the Telegram Login Widget to do a telegram login for my website with a telegram bot, however as this login session can be terminated by user from the "Privacy and Security" settings in the Telegram client, I'm trying to find a way to check…
hellopeach
  • 924
  • 8
  • 15
0
votes
0 answers

Sending audio to Telegram bot

I have a telegram bot bot.on("message", async function onAudio(msg) { const chatId = msg.chat.id const youtubeLink = msg.text // console.log(text); if (youtubeLink) { bot.sendMessage(chatId, 'Received your Link'); const stream =…
0
votes
1 answer

How to make that when you click on the text it was copied telegram bot api node.js

I am writing a telegram to the bot. I ran into such a problem. I need the bot to send a message (text) when clicked on which it was copied (as a token from @BotFather) I use node.js
0
votes
1 answer

Telegram bot responds in groups but not channels

I'm making a bot and need to let the user save the channelID to an array. The rest of the code is fine and works as intended in a group, but it's totally unresponsive inside a channel. I've if else statements for if the chat is a channel, group,…
Sean Fox
  • 11
  • 1