Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.5.1 to 0.6.0

test/sticker.webp

33

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

@@ -41,3 +41,32 @@ "main": "index.js",

},
"homepage": "https://github.com/yagop/node-telegram-bot-api"
"homepage": "https://github.com/yagop/node-telegram-bot-api",
"contributors": [
{
"name": "Ilias Ismanalijev",
"email": "hello@illyism.com",
"url": "https://github.com/Illyism",
"contributions": 3,
"additions": 52,
"deletions": 4,
"hireable": true
},
{
"name": "Yago",
"email": "yago@yago.me",
"url": "https://github.com/yagop",
"contributions": 38,
"additions": 947,
"deletions": 113,
"hireable": true
},
{
"name": "Riddler",
"email": "",
"url": "https://github.com/Waterloo",
"contributions": 3,
"additions": 64,
"deletions": 2,
"hireable": true
}
]
}

13

examples/polling.js

@@ -32,6 +32,13 @@ var TelegramBot = require('../src/telegram');

}
if (msg.text == '/help') {
var opts = {reply_to_message_id: msg.message_id};
bot.sendMessage(chatId, 'This is only a test :D', opts);
if (msg.text == '/love') {
var opts = {
reply_to_message_id: msg.message_id,
reply_markup: JSON.stringify({
keyboard: [
['Yes, you are the bot of my life ❤'],
['No, sorry there is another one...']]
})
};
bot.sendMessage(chatId, 'Do you love me?', opts);
}
});

@@ -135,2 +135,18 @@

## sendSticker(chatId, A, [options])
Send .webp stickers.
See: https://core.telegram.org/bots/api#sendsticker
### Params:
* **Number|String** *chatId* Unique identifier for the message recipient
* **String|stream.Stream** *A* file path or a Stream. Can also be a `file_id` previously uploaded.
* **Object** *[options]* Additional Telegram query options
### Return:
* **Promise**
## sendChatAction(chatId, action)

@@ -137,0 +153,0 @@

{
"name": "node-telegram-bot-api",
"version": "0.5.1",
"version": "0.6.0",
"description": "Telegram Bot API",

@@ -44,2 +44,11 @@ "main": "index.js",

{
"name": "Riddler",
"email": "",
"url": "https://github.com/Waterloo",
"contributions": 3,
"additions": 64,
"deletions": 2,
"hireable": true
},
{
"name": "Ilias Ismanalijev",

@@ -57,17 +66,8 @@ "email": "hello@illyism.com",

"url": "https://github.com/yagop",
"contributions": 38,
"additions": 947,
"deletions": 113,
"contributions": 43,
"additions": 1002,
"deletions": 132,
"hireable": true
},
{
"name": "Riddler",
"email": "",
"url": "https://github.com/Waterloo",
"contributions": 3,
"additions": 64,
"deletions": 2,
"hireable": true
}
]
}

@@ -27,2 +27,5 @@ [![Build Status](https://travis-ci.org/yagop/node-telegram-bot-api.svg?branch=master)](https://travis-ci.org/yagop/node-telegram-bot-api) [![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)

<!-- Start src/telegram.js -->
## TelegramBot

@@ -158,2 +161,18 @@

## sendSticker(chatId, A, [options])
Send .webp stickers.
See: https://core.telegram.org/bots/api#sendsticker
### Params:
* **Number|String** *chatId* Unique identifier for the message recipient
* **String|stream.Stream** *A* file path or a Stream. Can also be a `file_id` previously uploaded.
* **Object** *[options]* Additional Telegram query options
### Return:
* **Promise**
## sendChatAction(chatId, action)

@@ -176,2 +195,4 @@

* **Promise**
* **Promise**
<!-- End src/telegram.js -->

@@ -319,2 +319,22 @@ var EventEmitter = require('events').EventEmitter;

/**
* Send .webp stickers.
* @param {Number|String} chatId Unique identifier for the message recipient
* @param {String|stream.Stream} A file path or a Stream. Can
* also be a `file_id` previously uploaded.
* @param {Object} [options] Additional Telegram query options
* @return {Promise}
* @see https://core.telegram.org/bots/api#sendsticker
*/
TelegramBot.prototype.sendSticker = function (chatId, sticker, options) {
var opts = {
qs: options || {}
};
opts.qs.chat_id = chatId;
var content = this._formatSendData('sticker', sticker);
opts.formData = content[0];
opts.qs.sticker = content[1];
return this._request('sendSticker', opts);
};
/**
* Send chat action.

@@ -321,0 +341,0 @@ * `typing` for text messages,

@@ -204,6 +204,2 @@ var Telegram = require('../index');

});
describe('#sendDocument', function () {

@@ -249,1 +245,43 @@ var documentId;

});
describe('#sendSticker', function () {
var stickerId;
it('should send a sticker from file', function (done) {
var bot = new Telegram(TOKEN);
var sticker = __dirname+'/sticker.webp';
bot.sendSticker(USERID, sticker).then(function (resp) {
resp.should.be.an.instanceOf(Object);
stickerId = resp.sticker.file_id;
done();
});
});
it('should send a sticker from id', function (done) {
var bot = new Telegram(TOKEN);
// Send the same photo as before
bot.sendSticker(USERID, stickerId).then(function (resp) {
resp.should.be.an.instanceOf(Object);
done();
});
});
it('should send a sticker from fs.readStream', function (done) {
var bot = new Telegram(TOKEN);
var sticker = fs.createReadStream(__dirname+'/sticker.webp');
bot.sendSticker(USERID, sticker).then(function (resp) {
resp.should.be.an.instanceOf(Object);
done();
});
});
it('should send a sticker from request Stream', function (done) {
var bot = new Telegram(TOKEN);
var sticker = request('https://www.gstatic.com/webp/gallery3/1_webp_ll.webp');
bot.sendSticker(USERID, sticker).then(function (resp) {
resp.should.be.an.instanceOf(Object);
done();
});
});
});
});
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