2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-31 06:16:07 +00:00

src/telegram: Add sendVideoNote method (#330)

References:

    * API sendVideoNote method: https://core.telegram.org/bots/api#sendvideonote
    * PR: https://github.com/yagop/node-telegram-bot-api/pull/330
    * PR-by: @kamikazechaser 
    * API v3: https://github.com/yagop/node-telegram-bot-api/issues/332
This commit is contained in:
Mohammed Sohail
2017-05-26 16:25:34 +03:00
committed by Gocho Mugo
parent 4653bb1b38
commit 942fc4854b
3 changed files with 79 additions and 0 deletions

View File

@@ -709,6 +709,44 @@ describe('TelegramBot', function telegramSuite() {
});
});
describe('#sendVideoNote', function sendVideoNoteSuite() {
let videoNoteId;
this.timeout(timeout);
before(function before() {
utils.handleRatelimit(bot, 'sendVideoNote', this);
});
it('should send a video from file', function test() {
const video = `${__dirname}/data/video.mp4`;
return bot.sendVideoNote(USERID, video, { length: 5 }).then(resp => {
assert.ok(is.object(resp));
assert.ok(is.object(resp.video_note));
videoNoteId = resp.video_note.file_id;
});
});
it('should send a video from id', function test() {
// Send the same videonote as before
assert.ok(videoNoteId);
return bot.sendVideoNote(USERID, videoNoteId, { length: 5 }).then(resp => {
assert.ok(is.object(resp));
assert.ok(is.object(resp.video_note));
});
});
it('should send a video from fs.readStream', function test() {
const video = fs.createReadStream(`${__dirname}/data/video.mp4`);
return bot.sendVideoNote(USERID, video, { length: 5 }).then(resp => {
assert.ok(is.object(resp));
assert.ok(is.object(resp.video_note));
});
});
it('should send a video from a Buffer', function test() {
const video = fs.readFileSync(`${__dirname}/data/video.mp4`);
return bot.sendVideoNote(USERID, video, { length: 5 }).then(resp => {
assert.ok(is.object(resp));
assert.ok(is.object(resp.video_note));
});
});
});
describe('#sendVoice', function sendVoiceSuite() {
let voiceId;
this.timeout(timeout);