2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-29 13:27:44 +00:00

Add sendAnimation method

Reference: Telegram API Documentation: https://core.telegram.org/bots/api#sendanimation
This commit is contained in:
Mohammed Sohail 2018-08-01 22:29:09 +05:30
parent 2d3421905c
commit 8b99ccb75c
No known key found for this signature in database
GPG Key ID: 94B6F51820A503F9

View File

@ -838,6 +838,32 @@ class TelegramBot extends EventEmitter {
return this._request('sendVideo', opts); return this._request('sendVideo', opts);
} }
/**
* Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound).
* @param {Number|String} chatId Unique identifier for the message recipient
* @param {String|stream.Stream|Buffer} doc A file path, Stream or Buffer.
* Can also be a `file_id` previously uploaded.
* @param {Object} [options] Additional Telegram query options
* @param {Object} [fileOptions] Optional file related meta-data
* @return {Promise}
* @see https://core.telegram.org/bots/api#sendanimation
* @see https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#sending-files
*/
sendAnimation(chatId, animation, options = {}, fileOptions = {}) {
const opts = {
qs: options
};
opts.qs.chat_id = chatId;
try {
const sendData = this._formatSendData('animation', animation, fileOptions);
opts.formData = sendData[0];
opts.qs.document = sendData[1];
} catch (ex) {
return Promise.reject(ex);
}
return this._request('sendAnimation', opts);
}
/** /**
* Use this method to send rounded square videos of upto 1 minute long. * Use this method to send rounded square videos of upto 1 minute long.
* @param {Number|String} chatId Unique identifier for the message recipient * @param {Number|String} chatId Unique identifier for the message recipient