Skip to content

Commit ab9571c

Browse files
fix: rename parameter from thumb to thumbnail since Bot API 6.6 (#1123)
* Fix: field change from thumb to thumbnail * fix: backwards-compat of renamed thumbnail parameter --------- Co-authored-by: GochoMugo <mugo@forfuture.co.ke>
1 parent e239542 commit ab9571c

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/telegram.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,16 @@ class TelegramBot extends EventEmitter {
243243

244244
_fixAddFileThumbnail(options, opts) {
245245
if (options.thumb) {
246+
deprecate('The "thumb" parameter was renamed to "thumbnail" in Telegram Bot API v6.6. Please use the renamed parameter instead.');
247+
options.thumbnail = options.thumb;
248+
}
249+
if (options.thumbnail) {
246250
if (opts.formData === null) {
247251
opts.formData = {};
248252
}
249253

250254
const attachName = 'photo';
251-
const [formData] = this._formatSendData(attachName, options.thumb.replace('attach://', ''));
255+
const [formData] = this._formatSendData(attachName, options.thumbnail.replace('attach://', ''));
252256

253257
if (formData) {
254258
opts.formData[attachName] = formData[attachName];

test/telegram.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -752,14 +752,14 @@ describe('TelegramBot', function telegramSuite() {
752752
assert.ok(is.object(resp.audio));
753753
});
754754
});
755-
it('should send an audio file with thumb', function test() {
755+
it('should send an audio file with thumbnail', function test() {
756756
const audio = `${__dirname}/data/audio.mp3`;
757757
const thumbImg = `attach://${__dirname}/data/sticker_thumb.png`;
758758

759-
return bot.sendAudio(USERID, audio, { thumb: thumbImg }).then(resp => {
759+
return bot.sendAudio(USERID, audio, { thumbnail: thumbImg }).then(resp => {
760760
assert.ok(is.object(resp));
761761
assert.ok(is.object(resp.audio));
762-
assert.ok(is.object(resp.audio.thumb));
762+
assert.ok(is.object(resp.audio.thumbnail));
763763
});
764764
});
765765
});
@@ -1941,7 +1941,7 @@ describe('TelegramBot', function telegramSuite() {
19411941
utils.handleRatelimit(bot, 'setStickerSetThumbnail', this);
19421942
});
19431943

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

0 commit comments

Comments
 (0)