Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
58 lines (54 loc) · 1.89 KB
/
Copy pathindex.js
File metadata and controls
58 lines (54 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var debug = require('debug')('monkey-patches:node-telegram-bot-api');
function patchStopPolling(TelegramBot) {
TelegramBot.prototype.stopPolling = function () {
if (this._polling) {
this._polling.abort = true;
this._polling.lastRequest.cancel('Stop polling');
}
this._polling = null;
}
}
function patchEmitUpdate(TelegramBot) {
var _processUpdate = TelegramBot.prototype._processUpdate;
TelegramBot.prototype._processUpdate = function (update) {
debug('Process Update %j', update);
this.emit('update', update);
_processUpdate.call(this, update);
}
}
function patchSendVenue(TelegramBot) {
/**
* Send venue.
* Use this method to send information about a venue.
*
* @param {Number|String} chatId Unique identifier for the message recipient
* @param {Float} latitude Latitude of location
* @param {Float} longitude Longitude of location
* @param {String} title Name of the venue
* @param {String} address Address of the venue
* @param {Object} [options] Additional Telegram query options
* @return {Promise}
* @see https://core.telegram.org/bots/api#sendvenue
*/
TelegramBot.prototype.sendVenue = function sendVenue(chatId, latitude, longitude, title, address, form) {
form = form || {};
form.chat_id = chatId;
form.latitude = latitude;
form.longitude = longitude;
form.title = title;
form.address = address;
return this._request('sendVenue', {form: form});
}
}
module.exports = function (TelegramBot, options) {
options = options || {};
if (options.all || options.stopPolling) {
patchStopPolling(TelegramBot);
}
if (options.all || options.emitUpdate) {
patchEmitUpdate(TelegramBot);
}
if (options.all || options.sendVenue) {
patchSendVenue(TelegramBot);
}
};