describe('#getMyCommands ', function getMyCommandsSuite() { it('should get bot commands', function test() { return bot.getMyCommands().then(resp => { assert.ok(is.array(resp)); }); }); });
describe('#getStickerSet', function getStickerSetSuite() { before(function before() { utils.handleRatelimit(bot, 'getStickerSet', this); }); it('should get the sticker set given the name of the set', function test() { return bot.getStickerSet(STICKER_SET_NAME).then(resp => { assert.ok(is.object(resp)); assert.equal(resp.name.toLowerCase(), STICKER_SET_NAME); assert.ok(is.string(resp.title)); assert.ok(is.boolean(resp.contains_masks)); assert.ok(is.array(resp.stickers)); }); }); });
return bot.sendPhoto(USERID, photo).then(resp => { assert.ok(is.object(resp)); assert.ok(is.array(resp.photo)); photoId = resp.photo[0].file_id; }); return bot.sendPhoto(USERID, photo).then(resp => { assert.ok(is.object(resp)); assert.ok(is.array(resp.photo)); }); }); return bot.sendPhoto(USERID, photo).then(resp => { assert.ok(is.object(resp)); assert.ok(is.array(resp.photo)); }); }); return bot.sendPhoto(USERID, photo).then(resp => { assert.ok(is.object(resp)); assert.ok(is.array(resp.photo)); }); }); return bot.sendPhoto(USERID, photo).then(resp => { assert.ok(is.object(resp)); assert.ok(is.array(resp.photo)); }); });
describe('#getGameHighScores', function getGameHighScoresSuite() { before(function before() { utils.handleRatelimit(bot, 'getGameHighScores', this); }); it('should get GameHighScores', function test() { const opts = { chat_id: GAME_CHAT_ID, message_id: GAME_MSG_ID, }; return bot.getGameHighScores(USERID, opts).then(resp => { assert.ok(is.array(resp)); }); }); });
describe('#getUserProfilePhotos', function getUserProfilePhotosSuite() { const opts = { offset: 0, limit: 1, }; before(function before() { utils.handleRatelimit(bot, 'getUserProfilePhotos', this); }); it('should get user profile photos', function test() { return bot.getUserProfilePhotos(USERID, opts).then(resp => { assert.ok(is.object(resp)); assert.ok(is.number(resp.total_count)); assert.ok(is.array(resp.photos)); }); }); it('(v0.25.0 and lower) should get user profile photos', function test() { return bot.getUserProfilePhotos(USERID, opts.offset, opts.limit).then(resp => { assert.ok(is.object(resp)); assert.ok(is.number(resp.total_count)); assert.ok(is.array(resp.photos)); }); }); });
describe('#sendMediaGroup', function sendMediaGroupSuite() { before(function before() { utils.handleRatelimit(bot, 'sendMediaGroup', this); }); it('should send group of photos/videos as album', function test() { return bot.sendMediaGroup(USERID, [ { type: 'photo', media: `${__dirname}/data/photo.png`, }, { type: 'video', media: `${__dirname}/data/video.mp4`, }, { type: 'photo', media: FILE_ID, }, ], { disable_notification: true, }).then(resp => { assert.ok(is.array(resp)); assert.equal(resp.length, 3); }); }); });
hasListener(evtname, callback) { let handlers = this._listeners[evtname], idx; if (is.array(handlers) && (idx = handlers.indexOf(callback) !== -1)) { return true; } return false; }
promiseAll(promises) { if (!is.array(promises)) { promises = []; for (var i = 0; i < arguments.length; i++) { promises[i] = arguments[i]; } } return Q.promise.all(promises); }
function parseClsArgs(cls) { return array.mapArray(cls, (cls) => { if (is.string(cls)) { return cls.split(/\s+/g); } else if (is.array(cls)) { return array.mapArray(cls, cls => is.string(cls) ? cls.split(/\s+/g) : []); } else { return []; } }); }
fire(evtname, ...args) { let handlers = this._listeners[evtname]; if (is.array(handlers)) { handlers.forEach(function(h) { h.apply(this.__scope__, args); }.bind(this)); } }
uniquePush(array, ...vals) { if (!is.array(array)) { throw 'Invalid Array'; } return vals.filter(function(val) { if (array.indexOf(val) == -1) { array.push(val); return true; } return false; }); }
assignWith(target, includes, ...sources) { let keyFilter; if (is.array(includes) && includes.length > 0) { keyFilter = function(key) { return includes.indexOf(key) != -1; } } return _assign.apply(this, [target, keyFilter].concat(sources)); }
un(evtname, callback) { let handlers = this._listeners[evtname]; if (is.array(handlers)) { array.remove(handlers, callback); } }
remove(array, ...vals) { if (!is.array(array)) { throw 'Invalid Array'; } return vals.filter(function(val) { var idx, ret = false; while ((idx = array.indexOf(val)) != -1) { array.splice(idx, 1); ret = true; } return ret; }); }
assignWithout(target, excludes, ...sources) { let keyFilter; if (is.array(excludes) && excludes.length > 0) { keyFilter = function(key) { return excludes.indexOf(key) == -1; } } return _assign.apply(this, [target, keyFilter].concat(sources)); }