mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-28 21:07:39 +00:00
Closes #201: Add initial support for games
This commit is contained in:
commit
d35d0ea329
30
README.md
30
README.md
@ -92,6 +92,8 @@ TelegramBot
|
||||
* [.getChatMembersCount(chatId)](#TelegramBot+getChatMembersCount) ⇒ <code>Promise</code>
|
||||
* [.getChatMember(chatId, userId)](#TelegramBot+getChatMember) ⇒ <code>Promise</code>
|
||||
* [.leaveChat(chatId)](#TelegramBot+leaveChat) ⇒ <code>Promise</code>
|
||||
* [.sendGame(chatId, gameShortName, [options])](#TelegramBot+sendGame) ⇒ <code>Promise</code>
|
||||
* [.setGameScore(userId, score, [options])](#TelegramBot+setGameScore) ⇒ <code>Promise</code>
|
||||
|
||||
<a name="new_TelegramBot_new"></a>
|
||||
|
||||
@ -585,4 +587,32 @@ Leave a group, supergroup or channel.
|
||||
| --- | --- | --- |
|
||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target group or username of the target supergroup (in the format @supergroupusername) |
|
||||
|
||||
<a name="TelegramBot+sendGame"></a>
|
||||
|
||||
### telegramBot.sendGame(chatId, gameShortName, [options]) ⇒ <code>Promise</code>
|
||||
Use this method to send a game.
|
||||
|
||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||
**See**: https://core.telegram.org/bots/api#sendgame
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient |
|
||||
| gameShortName | <code>String</code> | name of the game to be sent. |
|
||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||
|
||||
<a name="TelegramBot+setGameScore"></a>
|
||||
|
||||
### telegramBot.setGameScore(userId, score, [options]) ⇒ <code>Promise</code>
|
||||
Use this method to set the score of the specified user in a game.
|
||||
|
||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||
**See**: https://core.telegram.org/bots/api#setgamescore
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| userId | <code>String</code> | Unique identifier of the target user |
|
||||
| score | <code>Number</code> | New score value. |
|
||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||
|
||||
* * *
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user