mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-22 09:57:10 +00:00
src/telegram: Add TelegramBot#getStickerSet()
References: * FR: https://github.com/yagop/node-telegram-bot-api/issues/407 * PR: https://github.com/yagop/node-telegram-bot-api/pull/429 * PR-by: @CapacitorSet, @libertylocked
This commit is contained in:
parent
f4f015a621
commit
a2d85b889a
@ -5,7 +5,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [Unreleased][Unreleased]
|
||||
|
||||
Added:
|
||||
|
||||
1. (#429) Add *TelegramBot#getStickerSet* (by @CapacitorSet, @LibertyLocked)
|
||||
|
||||
|
||||
* * *
|
||||
|
14
doc/api.md
14
doc/api.md
@ -75,6 +75,7 @@ TelegramBot
|
||||
* [.sendInvoice(chatId, title, description, payload, providerToken, startParameter, currency, prices, [options])](#TelegramBot+sendInvoice) ⇒ <code>Promise</code>
|
||||
* [.answerShippingQuery(shippingQueryId, ok, [options])](#TelegramBot+answerShippingQuery) ⇒ <code>Promise</code>
|
||||
* [.answerPreCheckoutQuery(preCheckoutQueryId, ok, [options])](#TelegramBot+answerPreCheckoutQuery) ⇒ <code>Promise</code>
|
||||
* [.getStickerSet(name, [options])](#TelegramBot+getStickerSet) ⇒ <code>Promise</code>
|
||||
* _static_
|
||||
* [.Promise](#TelegramBot.Promise)
|
||||
|
||||
@ -977,6 +978,19 @@ Use this method to confirm shipping of a product.
|
||||
| ok | <code>Boolean</code> | Specify if every order details are ok |
|
||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||
|
||||
<a name="TelegramBot+getStickerSet"></a>
|
||||
|
||||
### telegramBot.getStickerSet(name, [options]) ⇒ <code>Promise</code>
|
||||
Use this method to get a sticker set. On success, a [StickerSet](https://core.telegram.org/bots/api#stickerset) object is returned.
|
||||
|
||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||
**See**: https://core.telegram.org/bots/api#getstickerset
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| name | <code>String</code> | Name of the sticker set |
|
||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||
|
||||
<a name="TelegramBot.Promise"></a>
|
||||
|
||||
### TelegramBot.Promise
|
||||
|
@ -1499,6 +1499,19 @@ class TelegramBot extends EventEmitter {
|
||||
form.ok = ok;
|
||||
return this._request('answerPreCheckoutQuery', { form });
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to get a sticker set. On success, a [StickerSet](https://core.telegram.org/bots/api#stickerset) object is returned.
|
||||
*
|
||||
* @param {String} name Name of the sticker set
|
||||
* @param {Object} [options] Additional Telegram query options
|
||||
* @return {Promise}
|
||||
* @see https://core.telegram.org/bots/api#getstickerset
|
||||
*/
|
||||
getStickerSet(name, form = {}) {
|
||||
form.name = name;
|
||||
return this._request('getStickerSet', { form });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TelegramBot;
|
||||
|
@ -10,9 +10,14 @@ export TEST_USER_ID=<USER_ID>
|
||||
# Group Id which to use in some of the tests, e.g. for TelegramBot#getChat()
|
||||
export TEST_GROUP_ID=<GROUP_ID>
|
||||
|
||||
# Game short name which to use in some of the tests, e.g. TelegramBot#sendGame()
|
||||
# Game short name to use in some tests, e.g. TelegramBot#sendGame()
|
||||
# Defaults to "medusalab_test".
|
||||
export TEST_GAME_SHORT_NAME=<GAME_SHORT_NAME>
|
||||
|
||||
# Sticker set name to use in some tests, e.g. TelegramBot#getStickerSet()
|
||||
# Defaults to "pusheen".
|
||||
export TEST_STICKER_SET_NAME=<STICKER_SET_NAME>
|
||||
|
||||
# Payment provider token to be used
|
||||
export TEST_PROVIDER_TOKEN=<YOUR_PROVIDER_TOKEN>
|
||||
|
||||
|
@ -26,6 +26,7 @@ if (!PROVIDER_TOKEN && !isCI) { // If is not running in Travis / Appveyor
|
||||
const USERID = process.env.TEST_USER_ID || 777000;
|
||||
const GROUPID = process.env.TEST_GROUP_ID || -1001075450562;
|
||||
const GAME_SHORT_NAME = process.env.TEST_GAME_SHORT_NAME || 'medusalab_test';
|
||||
const STICKER_SET_NAME = process.env.TEST_STICKER_SET_NAME || 'pusheen';
|
||||
const timeout = 60 * 1000;
|
||||
let portindex = 8091;
|
||||
const staticPort = portindex++;
|
||||
@ -1355,4 +1356,19 @@ describe('TelegramBot', function telegramSuite() {
|
||||
describe.skip('#answerShippingQuery', function answerShippingQuerySuite() {});
|
||||
|
||||
describe.skip('#answerPreCheckoutQuery', function answerPreCheckoutQuerySuite() {});
|
||||
|
||||
describe('#getStickerSet', function getStickerSetSuite() {
|
||||
before(function before() {
|
||||
utils.handleRatelimit(bot, 'getStickerSet', this);
|
||||
});
|
||||
it('should get the sticker set given the name of the set', function test() {
|
||||
return bot.getStickerSet(STICKER_SET_NAME).then(resp => {
|
||||
assert.ok(is.object(resp));
|
||||
assert.equal(resp.name.toLowerCase(), STICKER_SET_NAME);
|
||||
assert.ok(is.string(resp.title));
|
||||
assert.ok(is.boolean(resp.contains_masks));
|
||||
assert.ok(is.array(resp.stickers));
|
||||
});
|
||||
});
|
||||
});
|
||||
}); // End Telegram
|
||||
|
Loading…
x
Reference in New Issue
Block a user