Socket
Socket
Sign inDemoInstall

node-telegram-bot-api

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-telegram-bot-api - npm Package Compare versions

Comparing version 0.19.2 to 0.20.0

examples/replyToMessage.js

2

package.json
{
"name": "node-telegram-bot-api",
"version": "0.19.2",
"version": "0.20.0",
"description": "Telegram Bot API",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -79,2 +79,3 @@ [![Build Status](https://travis-ci.org/yagop/node-telegram-bot-api.svg?branch=master)](https://travis-ci.org/yagop/node-telegram-bot-api) [![Build status](https://ci.appveyor.com/api/projects/status/ujko6bsum3g5msjh/branch/master?svg=true)](https://ci.appveyor.com/project/yagop/node-telegram-bot-api/branch/master) [![Coverage Status](https://coveralls.io/repos/yagop/node-telegram-bot-api/badge.svg?branch=master)](https://coveralls.io/r/yagop/node-telegram-bot-api?branch=master) [![bitHound Score](https://www.bithound.io/github/yagop/node-telegram-bot-api/badges/score.svg)](https://www.bithound.io/github/yagop/node-telegram-bot-api) [![https://telegram.me/node_telegram_bot_api](https://img.shields.io/badge/💬 Telegram-node__telegram__bot__api-blue.svg)](https://telegram.me/node_telegram_bot_api) [![https://telegram.me/Yago_Perez](https://img.shields.io/badge/💬 Telegram-Yago__Perez-blue.svg)](https://telegram.me/Yago_Perez)

* [.onText(regexp, callback)](#TelegramBot+onText)
* [.onReplyToMessage(messageId, callback)](#TelegramBot+onReplyToMessage)

@@ -345,2 +346,13 @@ <a name="new_TelegramBot_new"></a>

<a name="TelegramBot+onReplyToMessage"></a>
### telegramBot.onReplyToMessage(messageId, callback)
Register a reply to wait for a message response.
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
| Param | Type | Description |
| --- | --- | --- |
| messageId | <code>Number</code> &#124; <code>String</code> | The ID of the message to be replied |
| callback | <code>function</code> | Callback will be called with the reply message. |
* * *

@@ -46,2 +46,3 @@ 'use strict';

this.textRegexpCallbacks = [];
this.onReplyToMessages = [];

@@ -96,2 +97,15 @@ this.processUpdate = this._processUpdate.bind(this);

}
if (message.reply_to_message) {
// Only callbacks waiting for this message
this.onReplyToMessages.forEach(function (reply) {
// Message from the same chat
if (reply.chatId === message.chat.id) {
// Responding to that message
if (reply.messageId === message.reply_to_message.message_id) {
// Resolve the promise
reply.callback(message);
}
}
});
}
} else if (inline_query) {

@@ -554,2 +568,16 @@ debug('Process Update inline_query %j', inline_query);

/**
* Register a reply to wait for a message response.
* @param {Number|String} messageId The ID of the message to be replied
* @param {Function} callback Callback will be called with the reply
* message.
*/
TelegramBot.prototype.onReplyToMessage = function (chatId, messageId, callback) {
this.onReplyToMessages.push({
chatId: chatId,
messageId: messageId,
callback: callback
});
};
module.exports = TelegramBot;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc