mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-29 05:17:41 +00:00
Add TelegramBot#getChat() method
Notes: Merge branch 'master' of https://github.com/serhiidmytruk/node-telegram-bot-api into pr/144 References: * PR #144: https://github.com/yagop/node-telegram-bot-api/pull/144
This commit is contained in:
commit
e2eaa3c8db
10
README.md
10
README.md
@ -60,6 +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>
|
||||||
* [.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>
|
||||||
@ -119,6 +120,15 @@ Returns basic information about the bot in form of a `User` object.
|
|||||||
|
|
||||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||||
**See**: https://core.telegram.org/bots/api#getme
|
**See**: https://core.telegram.org/bots/api#getme
|
||||||
|
<a name="TelegramBot+getChat"></a>
|
||||||
|
|
||||||
|
### telegramBot.getChat() ⇒ <code>Promise</code>
|
||||||
|
Use this method to get up to date information about the chat
|
||||||
|
(current name of the user for one-on-one conversations, current
|
||||||
|
username of a user, group or channel, etc.).
|
||||||
|
|
||||||
|
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||||
|
**See**: https://core.telegram.org/bots/api#getchat
|
||||||
<a name="TelegramBot+setWebHook"></a>
|
<a name="TelegramBot+setWebHook"></a>
|
||||||
|
|
||||||
### telegramBot.setWebHook(url, [cert])
|
### telegramBot.setWebHook(url, [cert])
|
||||||
|
@ -205,6 +205,21 @@ class TelegramBot extends EventEmitter {
|
|||||||
return this._request(_path);
|
return this._request(_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to get up to date information about the chat
|
||||||
|
* (current name of the user for one-on-one conversations, current
|
||||||
|
* username of a user, group or channel, etc.).
|
||||||
|
* @return {Promise}
|
||||||
|
* @see https://core.telegram.org/bots/api#getchat
|
||||||
|
*/
|
||||||
|
getChat(chatId) {
|
||||||
|
const form = {
|
||||||
|
chat_id: chatId
|
||||||
|
};
|
||||||
|
|
||||||
|
return this._request('getChat', {form: form});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify an url to receive incoming updates via an outgoing webHook.
|
* Specify an url to receive incoming updates via an outgoing webHook.
|
||||||
* @param {String} url URL where Telegram will make HTTP Post. Leave empty to
|
* @param {String} url URL where Telegram will make HTTP Post. Leave empty to
|
||||||
|
@ -131,6 +131,15 @@ describe('Telegram', function telegramSuite() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#getChat', function getMeSuite() {
|
||||||
|
it('should return an User object', function test() {
|
||||||
|
const bot = new Telegram(TOKEN);
|
||||||
|
return bot.getChat(USERID).then(resp => {
|
||||||
|
assert.ok(is.object(resp));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('#getUpdates', function getUpdatesSuite() {
|
describe('#getUpdates', function getUpdatesSuite() {
|
||||||
it('should return an Array', function test() {
|
it('should return an Array', function test() {
|
||||||
const bot = new Telegram(TOKEN);
|
const bot = new Telegram(TOKEN);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user