mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-29 13:27:44 +00:00
Minor fixes and Docs update for PR #144
This commit is contained in:
parent
e2eaa3c8db
commit
f91d426c35
28
README.md
28
README.md
@ -60,7 +60,7 @@ TelegramBot
|
|||||||
* [new TelegramBot(token, [options])](#new_TelegramBot_new)
|
* [new TelegramBot(token, [options])](#new_TelegramBot_new)
|
||||||
* [.stopPolling()](#TelegramBot+stopPolling) ⇒ <code>Promise</code>
|
* [.stopPolling()](#TelegramBot+stopPolling) ⇒ <code>Promise</code>
|
||||||
* [.getMe()](#TelegramBot+getMe) ⇒ <code>Promise</code>
|
* [.getMe()](#TelegramBot+getMe) ⇒ <code>Promise</code>
|
||||||
* [.getChat()](#TelegramBot+getChat) ⇒ <code>Promise</code>
|
* [.getChat(chatId)](#TelegramBot+getChat) ⇒ <code>Promise</code>
|
||||||
* [.setWebHook(url, [cert])](#TelegramBot+setWebHook)
|
* [.setWebHook(url, [cert])](#TelegramBot+setWebHook)
|
||||||
* [.getUpdates([timeout], [limit], [offset])](#TelegramBot+getUpdates) ⇒ <code>Promise</code>
|
* [.getUpdates([timeout], [limit], [offset])](#TelegramBot+getUpdates) ⇒ <code>Promise</code>
|
||||||
* [.sendMessage(chatId, text, [options])](#TelegramBot+sendMessage) ⇒ <code>Promise</code>
|
* [.sendMessage(chatId, text, [options])](#TelegramBot+sendMessage) ⇒ <code>Promise</code>
|
||||||
@ -81,6 +81,7 @@ TelegramBot
|
|||||||
* [.editMessageReplyMarkup(replyMarkup, [options])](#TelegramBot+editMessageReplyMarkup) ⇒ <code>Promise</code>
|
* [.editMessageReplyMarkup(replyMarkup, [options])](#TelegramBot+editMessageReplyMarkup) ⇒ <code>Promise</code>
|
||||||
* [.getUserProfilePhotos(userId, [offset], [limit])](#TelegramBot+getUserProfilePhotos) ⇒ <code>Promise</code>
|
* [.getUserProfilePhotos(userId, [offset], [limit])](#TelegramBot+getUserProfilePhotos) ⇒ <code>Promise</code>
|
||||||
* [.sendLocation(chatId, latitude, longitude, [options])](#TelegramBot+sendLocation) ⇒ <code>Promise</code>
|
* [.sendLocation(chatId, latitude, longitude, [options])](#TelegramBot+sendLocation) ⇒ <code>Promise</code>
|
||||||
|
* [.sendVenue(chatId, latitude, longitude, title, address, [options])](#TelegramBot+sendVenue) ⇒ <code>Promise</code>
|
||||||
* [.getFile(fileId)](#TelegramBot+getFile) ⇒ <code>Promise</code>
|
* [.getFile(fileId)](#TelegramBot+getFile) ⇒ <code>Promise</code>
|
||||||
* [.getFileLink(fileId)](#TelegramBot+getFileLink) ⇒ <code>Promise</code>
|
* [.getFileLink(fileId)](#TelegramBot+getFileLink) ⇒ <code>Promise</code>
|
||||||
* [.downloadFile(fileId, downloadDir)](#TelegramBot+downloadFile) ⇒ <code>Promise</code>
|
* [.downloadFile(fileId, downloadDir)](#TelegramBot+downloadFile) ⇒ <code>Promise</code>
|
||||||
@ -122,13 +123,18 @@ Returns basic information about the bot in form of a `User` object.
|
|||||||
**See**: https://core.telegram.org/bots/api#getme
|
**See**: https://core.telegram.org/bots/api#getme
|
||||||
<a name="TelegramBot+getChat"></a>
|
<a name="TelegramBot+getChat"></a>
|
||||||
|
|
||||||
### telegramBot.getChat() ⇒ <code>Promise</code>
|
### telegramBot.getChat(chatId) ⇒ <code>Promise</code>
|
||||||
Use this method to get up to date information about the chat
|
Use this method to get up to date information about the chat
|
||||||
(current name of the user for one-on-one conversations, current
|
(current name of the user for one-on-one conversations, current
|
||||||
username of a user, group or channel, etc.).
|
username of a user, group or channel, etc.).
|
||||||
|
|
||||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||||
**See**: https://core.telegram.org/bots/api#getchat
|
**See**: https://core.telegram.org/bots/api#getchat
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) |
|
||||||
|
|
||||||
<a name="TelegramBot+setWebHook"></a>
|
<a name="TelegramBot+setWebHook"></a>
|
||||||
|
|
||||||
### telegramBot.setWebHook(url, [cert])
|
### telegramBot.setWebHook(url, [cert])
|
||||||
@ -436,6 +442,24 @@ Use this method to send point on the map.
|
|||||||
| longitude | <code>Float</code> | Longitude of location |
|
| longitude | <code>Float</code> | Longitude of location |
|
||||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
|
<a name="TelegramBot+sendVenue"></a>
|
||||||
|
|
||||||
|
### telegramBot.sendVenue(chatId, latitude, longitude, title, address, [options]) ⇒ <code>Promise</code>
|
||||||
|
Send venue.
|
||||||
|
Use this method to send information about a venue.
|
||||||
|
|
||||||
|
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||||
|
**See**: https://core.telegram.org/bots/api#sendvenue
|
||||||
|
|
||||||
|
| Param | Type | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| chatId | <code>Number</code> | <code>String</code> | Unique identifier for the message recipient |
|
||||||
|
| latitude | <code>Float</code> | Latitude of location |
|
||||||
|
| longitude | <code>Float</code> | Longitude of location |
|
||||||
|
| title | <code>String</code> | Name of the venue |
|
||||||
|
| address | <code>String</code> | Address of the venue |
|
||||||
|
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||||
|
|
||||||
<a name="TelegramBot+getFile"></a>
|
<a name="TelegramBot+getFile"></a>
|
||||||
|
|
||||||
### telegramBot.getFile(fileId) ⇒ <code>Promise</code>
|
### telegramBot.getFile(fileId) ⇒ <code>Promise</code>
|
||||||
|
@ -140,7 +140,7 @@ class TelegramBot extends EventEmitter {
|
|||||||
throw new Error(`Error parsing Telegram response: ${String(json)}`);
|
throw new Error(`Error parsing Telegram response: ${String(json)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_fixReplyMarkup(obj) {
|
_fixReplyMarkup(obj) {
|
||||||
const replyMarkup = obj.reply_markup;
|
const replyMarkup = obj.reply_markup;
|
||||||
if (replyMarkup && typeof replyMarkup !== 'string') {
|
if (replyMarkup && typeof replyMarkup !== 'string') {
|
||||||
@ -209,6 +209,7 @@ class TelegramBot extends EventEmitter {
|
|||||||
* Use this method to get up to date information about the chat
|
* Use this method to get up to date information about the chat
|
||||||
* (current name of the user for one-on-one conversations, current
|
* (current name of the user for one-on-one conversations, current
|
||||||
* username of a user, group or channel, etc.).
|
* username of a user, group or channel, etc.).
|
||||||
|
* @param {Number|String} chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @see https://core.telegram.org/bots/api#getchat
|
* @see https://core.telegram.org/bots/api#getchat
|
||||||
*/
|
*/
|
||||||
@ -216,8 +217,7 @@ class TelegramBot extends EventEmitter {
|
|||||||
const form = {
|
const form = {
|
||||||
chat_id: chatId
|
chat_id: chatId
|
||||||
};
|
};
|
||||||
|
return this._request('getChat', { form });
|
||||||
return this._request('getChat', {form: form});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -648,7 +648,7 @@ class TelegramBot extends EventEmitter {
|
|||||||
form.longitude = longitude;
|
form.longitude = longitude;
|
||||||
return this._request('sendLocation', { form });
|
return this._request('sendLocation', { form });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send venue.
|
* Send venue.
|
||||||
* Use this method to send information about a venue.
|
* Use this method to send information about a venue.
|
||||||
|
@ -131,8 +131,8 @@ describe('Telegram', function telegramSuite() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#getChat', function getMeSuite() {
|
describe('#getChat', function getChatSuite() {
|
||||||
it('should return an User object', function test() {
|
it('should return a Chat object', function test() {
|
||||||
const bot = new Telegram(TOKEN);
|
const bot = new Telegram(TOKEN);
|
||||||
return bot.getChat(USERID).then(resp => {
|
return bot.getChat(USERID).then(resp => {
|
||||||
assert.ok(is.object(resp));
|
assert.ok(is.object(resp));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user