mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-29 05:17:41 +00:00
pr: Merge edited PR (#439)
This commit is contained in:
commit
13472899e4
@ -7,6 +7,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
Added:
|
||||
|
||||
1. Add Bot API v3.4 methods:
|
||||
* (#439) *TelegramBot#editMessageLiveLocation*, *TelegramBot#stopMessageLiveLocation* (by @kamikazechaser)
|
||||
1. Add `metadata` argument in `message` event (and
|
||||
friends e.g. `text`, `audio`, etc.) (#409) (by @jlsjonas, @GochoMugo)
|
||||
1. Add support for Node.js v9 (by @GochoMugo)
|
||||
|
36
doc/api.md
36
doc/api.md
@ -55,6 +55,8 @@ TelegramBot
|
||||
* [.editMessageReplyMarkup(replyMarkup, [options])](#TelegramBot+editMessageReplyMarkup) ⇒ <code>Promise</code>
|
||||
* [.getUserProfilePhotos(userId, [options])](#TelegramBot+getUserProfilePhotos) ⇒ <code>Promise</code>
|
||||
* [.sendLocation(chatId, latitude, longitude, [options])](#TelegramBot+sendLocation) ⇒ <code>Promise</code>
|
||||
* [.editMessageLiveLocation(latitude, longitude, [options])](#TelegramBot+editMessageLiveLocation) ⇒ <code>Promise</code>
|
||||
* [.stopMessageLiveLocation([options])](#TelegramBot+stopMessageLiveLocation) ⇒ <code>Promise</code>
|
||||
* [.sendVenue(chatId, latitude, longitude, title, address, [options])](#TelegramBot+sendVenue) ⇒ <code>Promise</code>
|
||||
* [.sendContact(chatId, phoneNumber, firstName, [options])](#TelegramBot+sendContact) ⇒ <code>Promise</code>
|
||||
* [.getFile(fileId)](#TelegramBot+getFile) ⇒ <code>Promise</code>
|
||||
@ -702,6 +704,40 @@ Use this method to send point on the map.
|
||||
| longitude | <code>Float</code> | Longitude of location |
|
||||
| [options] | <code>Object</code> | Additional Telegram query options |
|
||||
|
||||
<a name="TelegramBot+editMessageLiveLocation"></a>
|
||||
|
||||
### telegramBot.editMessageLiveLocation(latitude, longitude, [options]) ⇒ <code>Promise</code>
|
||||
Use this method to edit live location messages sent by
|
||||
the bot or via the bot (for inline bots).
|
||||
|
||||
Note that you must provide one of chat_id, message_id, or
|
||||
inline_message_id in your request.
|
||||
|
||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||
**See**: https://core.telegram.org/bots/api#editmessagelivelocation
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| latitude | <code>Float</code> | Latitude of location |
|
||||
| longitude | <code>Float</code> | Longitude of location |
|
||||
| [options] | <code>Object</code> | Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here) |
|
||||
|
||||
<a name="TelegramBot+stopMessageLiveLocation"></a>
|
||||
|
||||
### telegramBot.stopMessageLiveLocation([options]) ⇒ <code>Promise</code>
|
||||
Use this method to stop updating a live location message sent by
|
||||
the bot or via the bot (for inline bots) before live_period expires.
|
||||
|
||||
Note that you must provide one of chat_id, message_id, or
|
||||
inline_message_id in your request.
|
||||
|
||||
**Kind**: instance method of <code>[TelegramBot](#TelegramBot)</code>
|
||||
**See**: https://core.telegram.org/bots/api#stopmessagelivelocation
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [options] | <code>Object</code> | Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here) |
|
||||
|
||||
<a name="TelegramBot+sendVenue"></a>
|
||||
|
||||
### telegramBot.sendVenue(chatId, latitude, longitude, title, address, [options]) ⇒ <code>Promise</code>
|
||||
|
@ -1185,6 +1185,40 @@ class TelegramBot extends EventEmitter {
|
||||
return this._request('sendLocation', { form });
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to edit live location messages sent by
|
||||
* the bot or via the bot (for inline bots).
|
||||
*
|
||||
* Note that you must provide one of chat_id, message_id, or
|
||||
* inline_message_id in your request.
|
||||
*
|
||||
* @param {Float} latitude Latitude of location
|
||||
* @param {Float} longitude Longitude of location
|
||||
* @param {Object} [options] Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)
|
||||
* @return {Promise}
|
||||
* @see https://core.telegram.org/bots/api#editmessagelivelocation
|
||||
*/
|
||||
editMessageLiveLocation(latitude, longitude, form = {}) {
|
||||
form.latitude = latitude;
|
||||
form.longitude = longitude;
|
||||
return this._request('editMessageLiveLocation', { form });
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to stop updating a live location message sent by
|
||||
* the bot or via the bot (for inline bots) before live_period expires.
|
||||
*
|
||||
* Note that you must provide one of chat_id, message_id, or
|
||||
* inline_message_id in your request.
|
||||
*
|
||||
* @param {Object} [options] Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here)
|
||||
* @return {Promise}
|
||||
* @see https://core.telegram.org/bots/api#stopmessagelivelocation
|
||||
*/
|
||||
stopMessageLiveLocation(form = {}) {
|
||||
return this._request('stopMessageLiveLocation', { form });
|
||||
}
|
||||
|
||||
/**
|
||||
* Send venue.
|
||||
* Use this method to send information about a venue.
|
||||
|
@ -39,6 +39,8 @@ const staticUrl = `http://127.0.0.1:${staticPort}`;
|
||||
const key = `${__dirname}/../examples/key.pem`;
|
||||
const ip = '216.58.210.174'; // Google IP ¯\_(ツ)_/¯
|
||||
const cert = `${__dirname}/../examples/crt.pem`;
|
||||
const lat = 47.5351072;
|
||||
const long = -52.7508537;
|
||||
let FILE_ID;
|
||||
let GAME_CHAT_ID;
|
||||
let GAME_MSG_ID;
|
||||
@ -1042,8 +1044,6 @@ describe('TelegramBot', function telegramSuite() {
|
||||
utils.handleRatelimit(bot, 'sendLocation', this);
|
||||
});
|
||||
it('should send a location', function test() {
|
||||
const lat = 47.5351072;
|
||||
const long = -52.7508537;
|
||||
return bot.sendLocation(USERID, lat, long).then(resp => {
|
||||
assert.ok(is.object(resp));
|
||||
assert.ok(is.object(resp.location));
|
||||
@ -1053,13 +1053,51 @@ describe('TelegramBot', function telegramSuite() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#editMessageLiveLocation', function editMessageLiveLocationSuite() {
|
||||
let message;
|
||||
before(function before() {
|
||||
utils.handleRatelimit(bot, 'editMessageLiveLocation', this);
|
||||
const opts = { live_period: 86400 };
|
||||
return bot.sendLocation(USERID, lat, long, opts).then(resp => { message = resp; });
|
||||
});
|
||||
it('edits live location', function test() {
|
||||
const opts = { chat_id: USERID, message_id: message.message_id };
|
||||
return bot.editMessageLiveLocation(lat + 1, long + 1, opts).then(resp => {
|
||||
assert.ok(is.object(resp));
|
||||
assert.ok(is.object(resp.location));
|
||||
assert.ok(is.number(resp.location.latitude));
|
||||
assert.ok(is.number(resp.location.longitude));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#stopMessageLiveLocation', function editMessageLiveLocationSuite() {
|
||||
let message;
|
||||
before(function before() {
|
||||
utils.handleRatelimit(bot, 'stopMessageLiveLocation', this);
|
||||
return bot.sendLocation(USERID, lat, long, { live_period: 86400 })
|
||||
.then((resp) => {
|
||||
message = resp;
|
||||
const opts = { chat_id: USERID, message_id: message.message_id };
|
||||
return bot.editMessageLiveLocation(lat + 1, long + 1, opts);
|
||||
});
|
||||
});
|
||||
it('stops location updates', function test() {
|
||||
const opts = { chat_id: USERID, message_id: message.message_id };
|
||||
return bot.stopMessageLiveLocation(opts).then(resp => {
|
||||
assert.ok(is.object(resp));
|
||||
assert.ok(is.object(resp.location));
|
||||
assert.ok(is.number(resp.location.latitude));
|
||||
assert.ok(is.number(resp.location.longitude));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#sendVenue', function sendVenueSuite() {
|
||||
before(function before() {
|
||||
utils.handleRatelimit(bot, 'sendVenue', this);
|
||||
});
|
||||
it('should send a venue', function test() {
|
||||
const lat = 47.5351072;
|
||||
const long = -52.7508537;
|
||||
const title = 'The Village Shopping Centre';
|
||||
const address = '430 Topsail Rd,St. John\'s, NL A1E 4N1, Canada';
|
||||
return bot.sendVenue(USERID, lat, long, title, address).then(resp => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user