Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Commit 924b79a

Browse files
committed
Align props names with Telegram bot api names
1 parent 9d6c664 commit 924b79a

13 files changed

+58
-59
lines changed

README.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Command with arguments `/say <your message>`:
115115
```js
116116
bot.on(/^\/say (.+)$/, (msg, props) => {
117117
const text = props.match[1];
118-
return bot.sendMessage(msg.from.id, text, { reply: msg.message_id });
118+
return bot.sendMessage(msg.from.id, text, { replyToMessage: msg.message_id });
119119
});
120120
```
121121

@@ -284,7 +284,7 @@ Use module function.
284284

285285
##### `keyboard([array of arrays], {resize, once, selective})`
286286

287-
Creates `ReplyKeyboardMarkup` keyboard `markup` object.
287+
Creates `ReplyKeyboardMarkup` keyboard `replyMarkup` object.
288288

289289
##### `button(<location | contact>, <text>)`
290290

@@ -330,63 +330,63 @@ Use this method to send `answerList` to an inline query.
330330

331331
Use this method to get basic info about a file and prepare it for downloading.
332332

333-
##### `sendMessage(<chat_id>, <text>, {parse, reply, markup, notify, preview})`
333+
##### `sendMessage(<chat_id>, <text>, {parseMode, replyToMessage, replyMarkup, notification, webPreview})`
334334

335335
Use this method to send text messages.
336336

337-
##### `forwardMessage(<chat_id>, <from_chat_id>, <message_id>, {notify})`
337+
##### `forwardMessage(<chat_id>, <from_chat_id>, <message_id>, {notification})`
338338

339339
Use this method to forward messages of any kind.
340340

341341
##### `deleteMessage(<chat_id>, <from_message_id>)`
342342

343343
Use this method to delete a message. A message can only be deleted if it was sent less than 48 hours ago. Any such sent outgoing message may be deleted. Additionally, if the bot is an administrator in a group chat, it can delete any message. If the bot is an administrator of a supergroup or channel, it can delete ordinary messages from any other user, including service messages about people added or removed from the chat. Returns *True* on success.
344344

345-
##### `sendPhoto(<chat_id>, <file_id | path | url | buffer | stream>, {caption, fileName, serverDownload, reply, markup, notify})`
345+
##### `sendPhoto(<chat_id>, <file_id | path | url | buffer | stream>, {caption, fileName, serverDownload, replyToMessage, replyMarkup, notification})`
346346

347347
Use this method to send photos.
348348

349-
##### `sendAudio(<chat_id>, <file_id | path | url | buffer | stream>, {title, performer, duration, caption, fileName, serverDownload, reply, markup, notify})`
349+
##### `sendAudio(<chat_id>, <file_id | path | url | buffer | stream>, {title, performer, duration, caption, fileName, serverDownload, replyToMessage, replyMarkup, notification})`
350350

351351
Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message.
352352

353-
##### `sendDocument(<chat_id>, <file_id | path | url | buffer | stream>, {caption, fileName, serverDownload, reply, markup, notify})`
353+
##### `sendDocument(<chat_id>, <file_id | path | url | buffer | stream>, {caption, fileName, serverDownload, replyToMessage, replyMarkup, notification})`
354354

355355
Use this method to send general files.
356356

357-
##### `sendSticker(<chat_id>, <file_id | path | url | buffer | stream>, {fileName, serverDownload, reply, markup, notify})`
357+
##### `sendSticker(<chat_id>, <file_id | path | url | buffer | stream>, {fileName, serverDownload, replyToMessage, replyMarkup, notification})`
358358

359359
Use this method to send `.webp` stickers.
360360

361-
##### `sendVideo(<chat_id>, <file_id | path | url | buffer | stream>, {duration, width, height, caption, fileName, serverDownload, reply, markup, notify})`
361+
##### `sendVideo(<chat_id>, <file_id | path | url | buffer | stream>, {duration, width, height, caption, fileName, serverDownload, replyToMessage, replyMarkup, notification})`
362362

363363
Use this method to send video files, Telegram clients support `mp4` videos (other formats may be sent as `Document`).
364364

365-
##### `sendVideoNote(<chat_id>, <file_id | path | url | buffer | stream>, {duration, length, fileName, serverDownload, reply, markup, notify})`
365+
##### `sendVideoNote(<chat_id>, <file_id | path | url | buffer | stream>, {duration, length, fileName, serverDownload, replyToMessage, replyMarkup, notification})`
366366

367367
Use this method to send video messages.
368368

369-
##### `sendVoice(<chat_id>, <file_id | path | url | buffer | stream>, {duration, caption, fileName, serverDownload, reply, markup, notify})`
369+
##### `sendVoice(<chat_id>, <file_id | path | url | buffer | stream>, {duration, caption, fileName, serverDownload, replyToMessage, replyMarkup, notification})`
370370

371371
Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message.
372372

373-
##### `sendLocation(<chat_id>, [<latitude>, <longitude>], {reply, markup, notify})`
373+
##### `sendLocation(<chat_id>, [<latitude>, <longitude>], {replyToMessage, replyMarkup, notification})`
374374

375375
Use this method to send point on the map.
376376

377-
##### `sendVenue(<chat_id>, [<latitude>, <longitude>], <title>, <address>, {foursquareId, reply, markup, notify})`
377+
##### `sendVenue(<chat_id>, [<latitude>, <longitude>], <title>, <address>, {foursquareId, replyToMessage, replyMarkup, notification})`
378378

379379
Use this method to send information about a venue.
380380

381-
##### `sendContact(<chat_id>, <number>, <firstName>, <lastName>, { reply, markup, notify})`
381+
##### `sendContact(<chat_id>, <number>, <firstName>, <lastName>, { replyToMessage, replyMarkup, notification})`
382382

383383
Use this method to send phone contacts.
384384

385385
##### `sendAction(<chat_id>, <action>)`
386386

387387
Use this method when you need to tell the user that something is happening on the bot's side. Choose one, depending on what the user is about to receive: *typing* for text messages, *upload_photo* for photos, *record_video* or *upload_video* for videos, *record_audio* or *upload_audio* for audio files, *upload_document* for general files, *find_location* for location data, *record_video_note* or *upload_video_note* for video notes.
388388

389-
##### `sendGame(<chat_id>, <game_short_name>, {notify, reply, markup})`
389+
##### `sendGame(<chat_id>, <game_short_name>, {notification, replyToMessage, replyMarkup})`
390390

391391
Use this method to send a game.
392392

@@ -406,7 +406,7 @@ Use this method to get a list of profile pictures for a user.
406406

407407
Use this method to get basic info about a file and prepare it for downloading.
408408

409-
##### `sendInvoice(<chat_id>, {title, description, payload, providerToken, startParameter, currency, prices, photo: {url, width, height}, need: {name, phoneNumber, email, shippingAddress}, isFlexible, notify, reply, markup})`
409+
##### `sendInvoice(<chat_id>, {title, description, payload, providerToken, startParameter, currency, prices, photo: {url, width, height}, need: {name, phoneNumber, email, shippingAddress}, isFlexible, notification, replyToMessage, replyMarkup})`
410410

411411
Use this method to send invoices.
412412

@@ -446,7 +446,7 @@ Use this method to edit text messages sent by the bot or via the bot (for inline
446446

447447
Use this method to edit captions of messages sent by the bot or via the bot (for inline bots).
448448

449-
##### `editMessageReplyMarkup` as `editMarkup({chatId & messageId | inlineMsgId}, <markup>)`
449+
##### `editMessageReplyMarkup` as `editMarkup({chatId & messageId | inlineMsgId}, <replyMarkup>)`
450450

451451
Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
452452

examples/KittyBot.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const bot = new TeleBot('TELEGRAM_BOT_TOKEN');
1010
const API = 'https://thecatapi.com/api/images/get?format=src&type=';
1111

1212
// Command keyboard
13-
const markup = bot.keyboard([
13+
const replyMarkup = bot.keyboard([
1414
['/kitty', '/kittygif']
1515
], {resize: true, once: false});
1616

@@ -23,7 +23,7 @@ bot.on('text', function (msg) {
2323
bot.on(['/start', '/help'], function (msg) {
2424

2525
return bot.sendMessage(msg.chat.id,
26-
'😺 Use commands: /kitty, /kittygif and /about', {markup}
26+
'😺 Use commands: /kitty, /kittygif and /about', {replyMarkup}
2727
);
2828

2929
});

examples/edit-markup.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ bot.on('callbackQuery', msg => {
2626

2727
const data = msg.data;
2828
const [chatId, messageId] = lastMessage;
29-
const markup = updateKeyboard(data);
29+
const replyMarkup = updateKeyboard(data);
3030

3131
// Edit message markup
32-
return bot.editMarkup({chatId, messageId}, {markup});
32+
return bot.editMarkup({chatId, messageId}, {replyMarkup});
3333

3434
});
3535

examples/edit-text.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function updateTime(chatId, messageId) {
1616
setInterval(() => {
1717
bot.editText(
1818
{chatId, messageId}, `<b>Current time:</b> ${ time() }`,
19-
{parse: 'html'}
19+
{parseMode: 'html'}
2020
).catch(error => console.log('Error:', error));
2121
}, 1000);
2222

examples/keyboard.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@ const bot = new TeleBot('TELEGRAM_BOT_TOKEN');
44
// On commands
55
bot.on(['/start', '/back'], msg => {
66

7-
let markup = bot.keyboard([
7+
let replyMarkup = bot.keyboard([
88
['/buttons', '/inlineKeyboard'],
99
['/start', '/hide']
1010
], {resize: true});
1111

12-
return bot.sendMessage(msg.from.id, 'Keyboard example.', {markup});
12+
return bot.sendMessage(msg.from.id, 'Keyboard example.', {replyMarkup});
1313

1414
});
1515

1616
// Buttons
1717
bot.on('/buttons', msg => {
1818

19-
let markup = bot.keyboard([
19+
let replyMarkup = bot.keyboard([
2020
[bot.button('contact', 'Your contact'), bot.button('location', 'Your location')],
2121
['/back', '/hide']
2222
], {resize: true});
2323

24-
return bot.sendMessage(msg.from.id, 'Button example.', {markup});
24+
return bot.sendMessage(msg.from.id, 'Button example.', {replyMarkup});
2525

2626
});
2727

2828
// Hide keyboard
2929
bot.on('/hide', msg => {
3030
return bot.sendMessage(
31-
msg.from.id, 'Hide keyboard example. Type /back to show.', {markup: 'hide'}
31+
msg.from.id, 'Hide keyboard example. Type /back to show.', {replyMarkup: 'hide'}
3232
);
3333
});
3434

@@ -40,7 +40,7 @@ bot.on(['location', 'contact'], (msg, self) => {
4040
// Inline buttons
4141
bot.on('/inlineKeyboard', msg => {
4242

43-
let markup = bot.inlineKeyboard([
43+
let replyMarkup = bot.inlineKeyboard([
4444
[
4545
bot.inlineButton('callback', {callback: 'this_is_data'}),
4646
bot.inlineButton('inline', {inline: 'some query'})
@@ -49,7 +49,7 @@ bot.on('/inlineKeyboard', msg => {
4949
]
5050
]);
5151

52-
return bot.sendMessage(msg.from.id, 'Inline keyboard example.', {markup});
52+
return bot.sendMessage(msg.from.id, 'Inline keyboard example.', {replyMarkup});
5353

5454
});
5555

examples/message-types.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ const bot = new TeleBot('TELEGRAM_BOT_TOKEN');
44
// On every type of message (& command)
55
bot.on(['*', '/*'], (msg, self) => {
66
let id = msg.from.id;
7-
let reply = msg.message_id;
7+
let replyToMessage = msg.message_id;
88
let type = self.type;
9-
let parse = 'html';
9+
let parseMode = 'html';
1010
return bot.sendMessage(
11-
id, `This is a <b>${ type }</b> message.`, {reply, parse}
11+
id, `This is a <b>${ type }</b> message.`, {replyToMessage, parseMode}
1212
);
1313
});
1414

examples/payment.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ bot.on('/start', (msg) => {
2121
{label: 'For testing!', amount: 1250},
2222
{label: 'Discount', amount: -120}
2323
],
24-
markup: inlineKeyboard
24+
replyMarkup: inlineKeyboard
2525
}).then(data => {
2626
console.log('OK', data);
2727
}).catch(error => {

examples/plugin-commandButton.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const bot = new TeleBot({
99
bot.on('/start', msg => {
1010

1111
// Inline keyboard markup
12-
const markup = bot.inlineKeyboard([
12+
const replyMarkup = bot.inlineKeyboard([
1313
[
1414
// First row with command callback button
1515
bot.inlineButton('Command button', {callback: '/hello'})
@@ -21,7 +21,7 @@ bot.on('/start', msg => {
2121
]);
2222

2323
// Send message with keyboard markup
24-
return bot.sendMessage(msg.from.id, 'Example of command button.', {markup});
24+
return bot.sendMessage(msg.from.id, 'Example of command button.', {replyMarkup});
2525

2626
});
2727

examples/plugin-namedButtons.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ const bot = new TeleBot({
2828

2929
bot.on('/hello', (msg) => msg.reply.text('Hello command!'));
3030
bot.on('/world', (msg) => msg.reply.text('World command!'));
31-
bot.on('/hide', (msg) => msg.reply.text('Type /start to show keyboard again.', {markup: 'hide'}));
31+
bot.on('/hide', (msg) => msg.reply.text('Type /start to show keyboard again.', {replyMarkup: 'hide'}));
3232

3333
bot.on('/start', (msg) => {
3434

35-
let markup = bot.keyboard([
35+
let replyMarkup = bot.keyboard([
3636
[BUTTONS.hello.label, BUTTONS.world.label],
3737
[BUTTONS.hide.label]
3838
], {resize: true});
3939

40-
return bot.sendMessage(msg.from.id, 'See keyboard below.', {markup});
40+
return bot.sendMessage(msg.from.id, 'See keyboard below.', {replyMarkup});
4141

4242
});
4343

lib/telebot.js

+13-14
Original file line numberDiff line numberDiff line change
@@ -478,29 +478,28 @@ class TeleBot {
478478

479479
properties(form = {}, opt = {}) {
480480

481-
// Reply to message
482-
if (opt.reply) form.reply_to_message_id = opt.reply;
481+
const parseMode = opt.parseMode || opt.parse;
482+
const replyToMessage = opt.replyToMessage || opt.reply;
483+
const replyMarkup = opt.replyMarkup || opt.markup;
484+
const notification = opt.notification === false || opt.notify === false;
485+
const webPreview = opt.webPreview === false || opt.preview === false;
483486

484-
// Markdown/HTML support for message
485-
if (opt.parse) form.parse_mode = opt.parse;
486-
487-
// User notification
488-
if (opt.notify === false) form.disable_notification = true;
489-
490-
// Web preview
491-
if (opt.preview === false) form.disable_web_page_preview = true;
487+
if (replyToMessage) form.reply_to_message_id = replyToMessage;
488+
if (parseMode) form.parse_mode = parseMode;
489+
if (notification) form.disable_notification = true;
490+
if (webPreview) form.disable_web_page_preview = true;
492491

493492
// Markup object
494-
if (opt.markup !== undefined) {
495-
if (opt.markup == 'hide' || opt.markup === false) {
493+
if (replyMarkup !== undefined) {
494+
if (replyMarkup == 'hide' || replyMarkup === false) {
496495
// Hide keyboard
497496
form.reply_markup = JSON.stringify({hide_keyboard: true});
498-
} else if (opt.markup == 'reply') {
497+
} else if (replyMarkup == 'reply') {
499498
// Fore reply
500499
form.reply_markup = JSON.stringify({force_reply: true});
501500
} else {
502501
// JSON keyboard
503-
form.reply_markup = JSON.stringify(opt.markup);
502+
form.reply_markup = JSON.stringify(replyMarkup);
504503
}
505504
}
506505

plugins/reporter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ module.exports = {
6363
`${ error.stack ? `🚧 <b>Stack:</b>\n${ s(error.stack) }\n` : '' }` +
6464
`⏰ <b>Event:</b> ${ type }\n` +
6565
`💾 <b>Data:</b> ${ jsonData }`,
66-
{parse: 'html', skipReport: true}
66+
{parseMode: 'html', skipReport: true}
6767
);
6868

6969
} else {
@@ -72,7 +72,7 @@ module.exports = {
7272
bot.sendMessage(userId,
7373
`⏰ <b>Event:</b> ${ type }\n` +
7474
(jsonData && jsonData != '{}' ? `💾 <b>Data:</b> ${ jsonData }` : ''),
75-
{parse: 'html', skipReport: true}
75+
{parseMode: 'html', skipReport: true}
7676
);
7777

7878
}

plugins/shortReply.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = {
3737

3838
function propertyProcessor(msg, props) {
3939
if (replyMode || props.asReply === true) {
40-
props.reply = msg.message_id;
40+
props.replyToMessage = msg.message_id;
4141
}
4242
return props;
4343
}

test/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,14 @@ test('bot.editCaption', t => {
254254
});
255255

256256
test('bot.editMarkup', t => {
257-
let markup = bot.inlineKeyboard([
257+
let replyMarkup = bot.inlineKeyboard([
258258
[bot.inlineButton('test', {callback: 1})]
259259
]);
260-
return bot.sendMessage(USER, 'markup', {markup}).then(re => {
260+
return bot.sendMessage(USER, 'markup', {replyMarkup}).then(re => {
261261
const chatId = USER;
262262
const messageId = re.result.message_id;
263-
markup = bot.inlineKeyboard([[bot.inlineButton('OK', {callback: 2})]]);
264-
return bot.editMarkup({chatId, messageId}, markup);
263+
replyMarkup = bot.inlineKeyboard([[bot.inlineButton('OK', {callback: 2})]]);
264+
return bot.editMarkup({chatId, messageId}, replyMarkup);
265265
}).then(re => t.true(re.ok));
266266
});
267267

0 commit comments

Comments
 (0)