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
3
votes
1 answer

Does bot api support creation of native polls?

I’m trying to have a bot that is part of a group conduct polls based on certain parameters it receives instead of the users of the group creating the polls themselves. Is this possible?
Carlos F
  • 893
  • 2
  • 12
  • 30
3
votes
4 answers

How should I download received files from telegram api

I just want to download images received by my telegram bot with nodejs but I dont know witch method to use. I'm using node-telegram-bot-api and I tried this code : bot.on('message', (msg) => { const img = bot.getFileLink(msg.photo[0].file_id); …
sidikfaha
  • 139
  • 3
  • 12
3
votes
1 answer

Number of monthly active users on a telegram channel?

telegram offers a measure of views of messages on a channel. I’m curious if there is a way to measure monthly active users or total unique views on a monthly basis on a particular group.
3
votes
1 answer

How to request all chats/groups of the user through Telegram Database Library(TDLib) for Node.js

The official example from telegram explains that in order to use getChats() command, one needs to set two parameters 'offset_order' and 'offset_chat_id'. I'm using this node.js wrapper for the TDLib. So when I use getChats() with the following…
Pets
  • 115
  • 10
3
votes
0 answers

How to get a Telegram Bot to search documents posted in a channel?

I was getting started with telegram bots and I was wondering if there's a way to get a BOT to search through the files posted in a channel (and possibly download them, if the user asks for it). For instance, if a BOT has a command "/search" and the…
3
votes
2 answers

Sequential execution of functions with node-telegram-bot-api

When I try to send information about my Age it is asking my Gen and then my height. And if I'm writing my height it's asking my gen 2 times and 1 time my age. How to make it work like this: It should ask something. then if I answer something and the…
3
votes
1 answer

How to get Telegram Bot Super Group ID?

How to get Telegram Bot Super Group ID? With This Code: bot.on('message', (msg) => { console.log(msg); }); I Can See my Private Channel ID in forward_from_chat: { id: -1001125265425, of the object, That is Okey. But How Can I Get Super Group…
Saeed Heidarizarei
  • 8,406
  • 21
  • 60
  • 103
3
votes
4 answers

Telegram bot inline keyboard via Node.JS

I'm using the node-telegram-bot-api module, How can I make my keyboard to inline Keyboard? This is my code: bot.onText(/^\/start$/, function (msg) { const opts = { reply_to_message_id: msg.message_id, reply_markup: { …
2
votes
0 answers

How to set default parse_mode in node-telegram-bot-api

bot.sendMessage(chatId,"hi",{parse_mode:"Markdown"}) I use this method , But I always want the same parsing mode, is there any way to do that ??
Afsal Cp
  • 21
  • 1
2
votes
1 answer

How to get video as response from youtube-dl?

I am writing a telegram bot to download a video from YouTube, I use the youtube-dl api, and when I try to get a video as response, but the video simply downloads to the root directory, but the script doesnt send it to the user, it gives me an…
JOKER
  • 75
  • 5
2
votes
1 answer

How to remove in node-telegram-bot-api only the bot.on() function?

How can I just remove the bot.on () in order to rerun the bot.onText ()? Because if I do bot.removeListener ('message') it also removes the bot.onText () bot.onText(/\/login/, (msg) => { bot.on('message', (msg) => { …
2
votes
0 answers

Is there a way to know if a message was deleted by channel members before i delete that message myself in telegram

Is there a way for me to know if the message send by my bot to a channel was deleted before i delete that message using deleteMessage method in Bot API in Telegram delete_message(channel_ID,message_ID) returns true even if the message was already…
2
votes
1 answer

How can I check if a person, through an invitation link, has brought more people to subscribe to my telegram channel?

I'm using Telebot with node.js and create my bot. In my bot, for each people, i send an invitation link about a Telegram Group.. i want the people, forward the link to friends and i want to check how many people join in my telegram group using that…
2
votes
1 answer

What should i do to get "telegram private group ids" new way

I want to create new bot that print users first name in telegram groups. So it could be easily done in public groups but in private groups I need its id so I have to add bot to private groups and then what should I do? I want to do it in Python or…
2
votes
1 answer

Telegram bot detect promotion to admin?

I have a TG bot that needs to pin a message. For this it needs admin rights. Is there an event that a TG bot can use to automatically detect when it is promoted so it automatically creates a message and pins it? Ok a related note, can the bot read…
1
2
3
10 11