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
1
vote
2 answers

How do I specify the dimensions of the video (height, width) when sending telegrams by bot?

I use the node-telegram-bot-api library. How do I specify the size of the video when sending it? // where to specify height and width ? bot.sendVideo( chatId, video, { caption: 'my video' }, { filename: 'my_file' }, ) The telegram API…
1
vote
0 answers

chat_member and my_chat_member dont work on this code in node-telegram-bot-api

bot.on('chat_member', async msg => { console.log(msg,'dsadsa')}) hi this event dont work in this lib node-telegram-bot-api but i dont know why? i seen there is no chat_member in codes `on(event: TelegramBot.MessageType | 'message', listener:…
Ezioadf2
  • 57
  • 6
1
vote
2 answers

add a callback to telegram-bot inline_keyboard to count button clicks

I am making a telegram-bot in NodeJS. This is a code snippet I am having an issue with: let counter = 0 bot.onText(/\flexbox (.+)/i, async (msg, match) => { console.log(msg) console.log(match) const chatId = msg.chat.id; …
1
vote
1 answer

Telegram bot privacy mode and groups

Is it possible to programmatically enable/disable privacy mode and groups mode for the bot? Can bot do it by itself?? Or only BotFather can do that? Also, is the 20 bots restriction per account still a thing?
Mugetsu
  • 1,739
  • 2
  • 20
  • 41
1
vote
0 answers

How can I get/write info about/in comments to telegram channel?

Is there a way to get information (ids, etc) about comments inside a channel post in telegram from telegram API ? Or is there an API method to write to the post comments? Could you provide some examples if this is possible? Thanks
1
vote
1 answer

How to send image from local folder with telegram bot?

I'm making telegram bot on nodeJs and I failed trying to find information on how to send local photo with bot. Official documentation says "upload a new photo using multipart/form-data". What does that mean ? If you now a better way of sending…
user8174006
1
vote
1 answer

Can I see whether message forwarded to the group has been edited and at what time?

Is there any way to see whether a message forwarded to the telegram channel from another channel has been edited (and at what time)? Via API or some other tools. Website version of telegram at web.telegram.org shows what time the forwarded message…
1
vote
2 answers

telegram bot | detect if user sent a message from mobile or desktop

I currently made bot with node-telegram-bot-api and a issue I face was I used emojis on a few messages the bot sends and realised few emojis of them are not supported in desktop. Can I detect if user sending message to my bot is in desktop so that I…
R. Gurung
  • 1,356
  • 1
  • 14
  • 34
1
vote
1 answer

how to test Telegram bot built with NodeJS?

I made a Telegram bot with NodeJS (node-telegram-bot-api) but right now I am facing an issue is to how to test the bot. I want to test how the bot responds when a message is given to it, how can I simulate that using Node itself and write automated…
R. Gurung
  • 1,356
  • 1
  • 14
  • 34
1
vote
1 answer

Telegram bot deep linking and scrolling to certain message

I've created a telegram bot and have many messages in the chat, I want to programmatically scroll to a certain message inside the chat, for example I want to have a link deep linked to a message in the chat so when I click on the link I would see…
1
vote
1 answer

Transfer control with inline buttons in telegram (bots)

If you have a bot-generated in-line button in a chat, that inline button can be used to take you to a bot. My question is - is the reverse possible? Can the bot have an inline button (when directly communicating with it) and it can transfer control…
1
vote
1 answer

Invite a friend to telegram channel

Is it possible to have an “inline button” on a channel that says “invite a friend” that forwards the private channel URL to friends on the channel. The idea is to make the “invitation process” for users to invite their friends much easier.
1
vote
1 answer

Possible to be anonymous from contacts on TG groups?

TG claims to be very private - my question is - is it possible to be part of a TG group that you have fellow contacts on, but those fellow contacts not to know you are on that group? So is it possible that 2 acquaintances message each other without…
1
vote
1 answer

Is it possible to programmatically approve users only to post to a channel on Telegram?

I want to create a group dynamic with anonymity on Telegram. I get that you can use any username and be anonymous on telegram but if you are on someone’s contact list, they can always message you - even if you change your username. So you cannot be…
1
vote
1 answer

Is it possible to programmatically pre-approve a user to a telegram group or channel

I want to allow only users from a particular school - say Harvard - to access a telegram group. So, I need the person to “register” - say on a bot and share his abc@harvard.edu email address. I then verify the email through a verification code. He…