Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: field change from thumb to thumbnail since Bot API 6.6 #1123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/telegram.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ class TelegramBot extends EventEmitter {
}

_fixAddFileThumbnail(options, opts) {
if (options.thumb) {
if (options.thumbnail) {
if (opts.formData === null) {
opts.formData = {};
}

const attachName = 'photo';
const [formData] = this._formatSendData(attachName, options.thumb.replace('attach://', ''));
const [formData] = this._formatSendData(attachName, options.thumbnail.replace('attach://', ''));

if (formData) {
opts.formData[attachName] = formData[attachName];
Expand Down
8 changes: 4 additions & 4 deletions test/telegram.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,14 +730,14 @@ describe('TelegramBot', function telegramSuite() {
assert.ok(is.object(resp.audio));
});
});
it('should send an audio file with thumb', function test() {
it('should send an audio file with thumbnail', function test() {
const audio = `${__dirname}/data/audio.mp3`;
const thumbImg = `attach://${__dirname}/data/sticker_thumb.png`;

return bot.sendAudio(USERID, audio, { thumb: thumbImg }).then(resp => {
return bot.sendAudio(USERID, audio, { thumbnail: thumbImg }).then(resp => {
assert.ok(is.object(resp));
assert.ok(is.object(resp.audio));
assert.ok(is.object(resp.audio.thumb));
assert.ok(is.object(resp.audio.thumbnail));
});
});
});
Expand Down Expand Up @@ -1916,7 +1916,7 @@ describe('TelegramBot', function telegramSuite() {
utils.handleRatelimit(bot, 'setStickerSetThumbnail', this);
});

it('should set a sticker set thumb', function test() {
it('should set a sticker set thumbnail', function test() {
const stickerThumb = `${__dirname}/data/sticker_thumb.png`;
const stickerPackName = `s${CURRENT_TIMESTAMP}_by_${BOT_USERNAME}`;

Expand Down