diff --git a/README.md b/README.md index 326f504..748f373 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,8 @@ TelegramBot * [.getChatMembersCount(chatId)](#TelegramBot+getChatMembersCount) ⇒ Promise * [.getChatMember(chatId, userId)](#TelegramBot+getChatMember) ⇒ Promise * [.leaveChat(chatId)](#TelegramBot+leaveChat) ⇒ Promise + * [.sendGame(chatId, gameShortName, [options])](#TelegramBot+sendGame) ⇒ Promise + * [.setGameScore(userId, score, [options])](#TelegramBot+setGameScore) ⇒ Promise @@ -585,4 +587,32 @@ Leave a group, supergroup or channel. | --- | --- | --- | | chatId | Number | String | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) | + + +### telegramBot.sendGame(chatId, gameShortName, [options]) ⇒ Promise +Use this method to send a game. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#sendgame + +| Param | Type | Description | +| --- | --- | --- | +| chatId | Number | String | Unique identifier for the message recipient | +| gameShortName | String | name of the game to be sent. | +| [options] | Object | Additional Telegram query options | + + + +### telegramBot.setGameScore(userId, score, [options]) ⇒ Promise +Use this method to set the score of the specified user in a game. + +**Kind**: instance method of [TelegramBot](#TelegramBot) +**See**: https://core.telegram.org/bots/api#setgamescore + +| Param | Type | Description | +| --- | --- | --- | +| userId | String | Unique identifier of the target user | +| score | Number | New score value. | +| [options] | Object | Additional Telegram query options | + * * * diff --git a/src/telegram.js b/src/telegram.js index 1119688..9648135 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -809,6 +809,34 @@ class TelegramBot extends EventEmitter { }; return this._request('leaveChat', { form }); } + + /** + * Use this method to send a game. + * @param {Number|String} chatId Unique identifier for the message recipient + * @param {String} gameShortName name of the game to be sent. + * @param {Object} [options] Additional Telegram query options + * @return {Promise} + * @see https://core.telegram.org/bots/api#sendgame + */ + sendGame(chatId, gameShortName, form = {}) { + form.chat_id = chatId; + form.game_short_name = gameShortName; + return this._request('sendGame', { form }); + } + + /** + * Use this method to set the score of the specified user in a game. + * @param {String} userId Unique identifier of the target user + * @param {Number} score New score value. + * @param {Object} [options] Additional Telegram query options + * @return {Promise} + * @see https://core.telegram.org/bots/api#setgamescore + */ + setGameScore(userId, score, form = {}) { + form.user_id = userId; + form.score = score; + return this._request('setGameScore', { form }); + } } module.exports = TelegramBot;