2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-31 22:35:38 +00:00

feat: Telegram Bot API Support 6.6 + 6.7 [WIP] (#1069)

* feat: Telegram Bot API Support

* refactor: uploadStickerFile

* feat: Support Telegram Bot API v6.7

* fix: tests

* feat: Test for deleteStickerSet
This commit is contained in:
Daniel Pérez Fernández
2023-08-23 00:49:09 +02:00
committed by GitHub
parent 2885db0e31
commit 542002ec0d
4 changed files with 571 additions and 36 deletions

View File

@@ -50,6 +50,7 @@ let GAME_MSG_ID;
let BOT_USERNAME;
let CHAT_INFO;
let STICKER_FILE_ID_FROM_SET;
let STICKERS_FROM_BOT_SET;
before(function beforeAll() {
utils.startStaticServer(staticPort);
@@ -1418,6 +1419,74 @@ describe('TelegramBot', function telegramSuite() {
});
});
describe('#setMyDescription', function getMyCommandsSuite() {
it('should set bot description for users with a specific lang code', function test() {
return bot.setMyDescription({ description: 'Bot description' }).then(resp => {
assert.ok(is.boolean(resp));
});
});
it('should set bot description for Spanish users', function test() {
return bot.setMyDescription({ description: 'Spanish bot description', language_code: 'es' }).then(resp => {
assert.ok(is.boolean(resp));
});
});
});
describe('#setMyName', function setMyNameSuite() {
it('should set bot name for Spanish users', function test() {
return bot.setMyName({ name: 'Spanish Bot', language_code: 'es' }).then(resp => {
assert.ok(is.boolean(resp));
});
});
});
describe('#getMyName', function setMyNameSuite() {
it('should get bot name for Spanish users', function test() {
return bot.getMyName({ language_code: 'es' }).then(resp => {
assert.ok(is.equal(resp.name, 'Spanish Bot'));
});
});
});
describe('#getMyDescription', function getMyDescriptionSuite() {
it('should get bot description for a user without lang code', function test() {
return bot.getMyDescription().then(resp => {
assert.ok(is.equal(resp.description, 'Bot description'));
});
});
it('should get bot description for Spanish users', function test() {
return bot.getMyDescription({ language_code: 'es' }).then(resp => {
assert.ok(is.equal(resp.description, 'Spanish bot description'));
});
});
});
describe('#setMyShortDescription', function setMyShortDescriptionSuite() {
it('should set sort bot description for a user without lang code', function test() {
return bot.setMyShortDescription({ short_description: 'Bot sort description' }).then(resp => {
assert.ok(is.boolean(resp));
});
});
it('should set sort description for Spanish users', function test() {
return bot.setMyShortDescription({ short_description: 'Spanish bot sort description', language_code: 'es' }).then(resp => {
assert.ok(is.boolean(resp));
});
});
});
describe('#getMyShortDescription', function getMyShortDescriptionSuite() {
it('should get bot sort description for a user without lang code', function test() {
return bot.getMyShortDescription().then(resp => {
assert.ok(is.equal(resp.short_description, 'Bot sort description'));
});
});
it('should get bot sort description for Spanish users', function test() {
return bot.getMyShortDescription({ language_code: 'es' }).then(resp => {
assert.ok(is.equal(resp.short_description, 'Spanish bot sort description'));
});
});
});
describe('#getMyCommands', function getMyCommandsSuite() {
it('should get bot commands', function test() {
return bot.getMyCommands().then(resp => {
@@ -1781,16 +1850,105 @@ describe('TelegramBot', function telegramSuite() {
});
});
describe('#setStickerSetThumb', function setStickerSetThumbSuite() {
describe('#setStickerEmojiList', function setStickerEmojiListSuite() {
before(function before() {
utils.handleRatelimit(bot, 'setStickerSetThumb', this);
utils.handleRatelimit(bot, 'setStickerEmojiList', this);
});
it('should get the list for the given sticker of the bot sticker pack', function test(done) {
const stickerPackName = `s${CURRENT_TIMESTAMP}_by_${BOT_USERNAME}`;
bot.getStickerSet(stickerPackName).then(resp => {
STICKERS_FROM_BOT_SET = resp.stickers;
assert.ok(is.array(STICKERS_FROM_BOT_SET));
});
setTimeout(() => done(), 2000);
});
it('should set a emoji list for the given sticker', function test() {
assert.ok(is.equal(STICKERS_FROM_BOT_SET[0].type, 'regular'));
bot.setStickerEmojiList(STICKERS_FROM_BOT_SET[0].file_id, ['🥳', '😀', '😇']).then((resp) => {
assert.ok(is.boolean(resp));
});
});
});
describe('#setStickerKeywords', function setStickerKeywordsSuite() {
before(function before() {
utils.handleRatelimit(bot, 'setStickerKeywords', this);
});
it('should set a keywords list for the given sticker', function test() {
assert.ok(is.equal(STICKERS_FROM_BOT_SET[0].type, 'regular'));
bot.setStickerKeywords(STICKERS_FROM_BOT_SET[0].file_id, { keywords: ['house', 'cat'] }).then((resp) => {
assert.ok(is.boolean(resp));
});
});
});
describe.skip('#setStickerMaskPosition', function setStickerKeywordsSuite() {
before(function before() {
utils.handleRatelimit(bot, 'setStickerMaskPosition', this);
});
it('should delete a sticker from a set', function test() {
bot.setStickerMaskPosition(STICKER_FILE_ID_FROM_SET, { point: 'eyes', scale: 2, x_shift: 1, y_shift: 1 }).then((resp) => {
assert.ok(is.boolean(resp));
});
});
});
describe('#setStickerSetTitle', function setStickerSetTitleSuite() {
before(function before() {
utils.handleRatelimit(bot, 'setStickerSetTitle', this);
});
it('should set a new sticker set title', function test() {
const stickerPackName = `s${CURRENT_TIMESTAMP}_by_${BOT_USERNAME}`;
bot.setStickerSetTitle(stickerPackName, 'New title').then((resp) => {
assert.ok(is.boolean(resp));
});
});
});
describe('#setStickerSetThumbnail', function setStickerSetThumbnailSuite() {
before(function before() {
utils.handleRatelimit(bot, 'setStickerSetThumbnail', this);
});
it('should set a sticker set thumb', function test() {
const stickerThumb = `${__dirname}/data/sticker_thumb.png`;
const stickerPackName = `s${CURRENT_TIMESTAMP}_by_${BOT_USERNAME}`;
bot.setStickerSetThumb(USERID, stickerPackName, stickerThumb).then((resp) => {
bot.setStickerSetThumbnail(USERID, stickerPackName, stickerThumb).then((resp) => {
assert.ok(is.boolean(resp));
});
});
});
describe.skip('#setCustomEmojiStickerSetThumbnail', function setCustomEmojiStickerSetThumbnailSuite() {
before(function before() {
utils.handleRatelimit(bot, 'setCustomEmojiStickerSetThumbnail', this);
});
it('should set a custom emoji sticjer set as thumbnail', function test() {
const stickerPackName = `s${CURRENT_TIMESTAMP}_by_${BOT_USERNAME}`;
bot.setCustomEmojiStickerSetThumbnail(stickerPackName, { custom_emoji_id: null }).then((resp) => {
assert.ok(is.boolean(resp));
});
});
});
describe.skip('#deleteStickerSet', function deleteStickerSetSuite() {
before(function before() {
utils.handleRatelimit(bot, 'deleteStickerSet', this);
});
it('should delete sticker set', function test() {
const stickerPackName = `s${CURRENT_TIMESTAMP}_by_${BOT_USERNAME}`;
bot.deleteStickerSet(stickerPackName).then((resp) => {
assert.ok(is.boolean(resp));
});
});