2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-29 13:27:44 +00:00

Changed query to form data on sendMessage, forwardMessage, sendChatAction, getUserProfilePhotos, sendLocation and getFile. Closes #19

This commit is contained in:
Yago 2015-09-27 11:07:26 +02:00
parent 1a2163dee2
commit 48045b98ff

View File

@ -131,8 +131,8 @@ TelegramBot.prototype.getMe = function () {
*/ */
TelegramBot.prototype.setWebHook = function (url) { TelegramBot.prototype.setWebHook = function (url) {
var path = 'setWebHook'; var path = 'setWebHook';
var qs = {url: url}; var form = {url: url};
return this._request(path, {qs: qs}) return this._request(path, {form: form})
.then(function (resp) { .then(function (resp) {
if (!resp) { if (!resp) {
throw new Error(resp); throw new Error(resp);
@ -150,13 +150,13 @@ TelegramBot.prototype.setWebHook = function (url) {
* @see https://core.telegram.org/bots/api#getupdates * @see https://core.telegram.org/bots/api#getupdates
*/ */
TelegramBot.prototype.getUpdates = function (timeout, limit, offset) { TelegramBot.prototype.getUpdates = function (timeout, limit, offset) {
var query = { var form = {
offset: offset, offset: offset,
limit: limit, limit: limit,
timeout: timeout timeout: timeout
}; };
return this._request('getUpdates', {qs: query}); return this._request('getUpdates', {form: form});
}; };
/** /**
@ -168,10 +168,10 @@ TelegramBot.prototype.getUpdates = function (timeout, limit, offset) {
* @see https://core.telegram.org/bots/api#sendmessage * @see https://core.telegram.org/bots/api#sendmessage
*/ */
TelegramBot.prototype.sendMessage = function (chatId, text, options) { TelegramBot.prototype.sendMessage = function (chatId, text, options) {
var query = options || {}; var form = options || {};
query.chat_id = chatId; form.chat_id = chatId;
query.text = text; form.text = text;
return this._request('sendMessage', {qs: query}); return this._request('sendMessage', {form: form});
}; };
/** /**
@ -183,12 +183,12 @@ TelegramBot.prototype.sendMessage = function (chatId, text, options) {
* @return {Promise} * @return {Promise}
*/ */
TelegramBot.prototype.forwardMessage = function (chatId, fromChatId, messageId) { TelegramBot.prototype.forwardMessage = function (chatId, fromChatId, messageId) {
var query = { var form = {
chat_id: chatId, chat_id: chatId,
from_chat_id: fromChatId, from_chat_id: fromChatId,
message_id: messageId message_id: messageId
}; };
return this._request('forwardMessage', {qs: query}); return this._request('forwardMessage', {form: form});
}; };
TelegramBot.prototype._formatSendData = function (type, data) { TelegramBot.prototype._formatSendData = function (type, data) {
@ -355,11 +355,11 @@ TelegramBot.prototype.sendVoice = function (chatId, voice, options) {
* @see https://core.telegram.org/bots/api#sendchataction * @see https://core.telegram.org/bots/api#sendchataction
*/ */
TelegramBot.prototype.sendChatAction = function (chatId, action) { TelegramBot.prototype.sendChatAction = function (chatId, action) {
var query = { var form = {
chat_id: chatId, chat_id: chatId,
action: action action: action
}; };
return this._request('sendChatAction', {qs: query}); return this._request('sendChatAction', {form: form});
}; };
/** /**
@ -373,12 +373,12 @@ TelegramBot.prototype.sendChatAction = function (chatId, action) {
* @see https://core.telegram.org/bots/api#getuserprofilephotos * @see https://core.telegram.org/bots/api#getuserprofilephotos
*/ */
TelegramBot.prototype.getUserProfilePhotos = function (userId, offset, limit) { TelegramBot.prototype.getUserProfilePhotos = function (userId, offset, limit) {
var query = { var form = {
user_id: userId, user_id: userId,
offset: offset, offset: offset,
limit: limit limit: limit
}; };
return this._request('getUserProfilePhotos', {qs: query}); return this._request('getUserProfilePhotos', {form: form});
}; };
/** /**
@ -393,11 +393,11 @@ TelegramBot.prototype.getUserProfilePhotos = function (userId, offset, limit) {
* @see https://core.telegram.org/bots/api#sendlocation * @see https://core.telegram.org/bots/api#sendlocation
*/ */
TelegramBot.prototype.sendLocation = function (chatId, latitude, longitude, options) { TelegramBot.prototype.sendLocation = function (chatId, latitude, longitude, options) {
var query = options || {}; var form = options || {};
query.chat_id = chatId; form.chat_id = chatId;
query.latitude = latitude; form.latitude = latitude;
query.longitude = longitude; form.longitude = longitude;
return this._request('sendLocation', {qs: query}); return this._request('sendLocation', {form: form});
}; };
/** /**
@ -410,10 +410,8 @@ TelegramBot.prototype.sendLocation = function (chatId, latitude, longitude, opti
* @see https://core.telegram.org/bots/api#getfile * @see https://core.telegram.org/bots/api#getfile
*/ */
TelegramBot.prototype.getFile = function(fileId) { TelegramBot.prototype.getFile = function(fileId) {
var form = {file_id: fileId};
var query = { file_id: fileId }; return this._request('getFile', {form: form});
return this._request('getFile', {qs: query});
}; };
/** /**