Skip to content

Commit b4dc9c0

Browse files
committed
Changes
1 parent a35d971 commit b4dc9c0

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

examples/inline-query.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ const TeleBot = require('../');
1010
const bot = new TeleBot('-PASTEYOURTELEGRAMBOTAPITOKENHERE-');
1111

1212
// On inline query
13-
bot.on('inlineQuery', data => {
13+
bot.on('inlineQuery', msg => {
1414

15-
let query = data.query;
15+
let query = msg.query;
1616
console.log(`inline query: ${ query }`);
1717

1818
// Create a new answer list object
19-
const answers = bot.answerList(data.id);
19+
const answers = bot.answerList(msg.id);
2020

2121
// Cache time in seconds (defaults to 300)
2222
answers.cacheTime = 60;

examples/message-types.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ bot.on(['*', '/*'], (msg, self) => {
99
let reply = msg.message_id;
1010
let type = self.type;
1111
let parse = 'html';
12-
return bot.sendMessage(id, `This is a <b>${ type }</b>.`, { reply, parse });
12+
return bot.sendMessage(
13+
id, `This is a <b>${ type }</b> message.`, { reply, parse }
14+
);
1315
});
1416

1517
bot.connect();
File renamed without changes.

lib/telebot.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ TeleBot.addMethods(standardMethods);
434434
function eventPromiseError(type, fired, error) {
435435
return new Promise((resolve, reject) => {
436436
console.error('[bot.error.event]', error.stack || error);
437-
if (type != 'error.event') {
437+
if (type != 'error' && type != 'error.event') {
438438
this.event(['error', 'error.event'], { error, data: fired.data })
439439
.then(resolve).catch(reject);
440440
} else {

lib/updates.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
// Command regexp
4-
const reCMD = /^\/([а-я\w\d]+)/;
4+
const reCMD = /^\/([0-9а-я\w\d\_\-]+)/;
55

66
// Message types
77
const MESSAGE_TYPES = [
@@ -47,11 +47,8 @@ module.exports = {
4747
const match = reCMD.exec(update.text);
4848
if (!match) continue;
4949

50-
// Set type
51-
props.type = 'command';
52-
5350
// Command found
54-
props.cmd = update.text.split(' ');
51+
props.type = 'command';
5552
promise = promise.then(x => {
5653
return this.event(['/*', '/' + match[1]], update, props);
5754
});

modules/botan.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@
99

1010
'use strict';
1111

12-
module.exports = (bot, cfg) {
12+
module.exports = (bot, cfg) => {
1313

1414
// Check AppMetrika key
1515
const TOKEN = cfg.botan;
16+
17+
// On no token
1618
if (!TOKEN) return console.error('[botan] no token key');
1719

20+
// Require botanio
1821
const botan = require('botanio')(TOKEN);
1922

2023
// Track every type of message
21-
bot.on('*', msg => {
22-
botan.track(msg, this.type);
23-
});
24+
bot.on('*', (msg, props) => botan.track(msg, props.type));
2425

2526
};

modules/report.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports = (bot, cfg) => {
3434
return console.error('[report] no event list');
3535

3636
// Create events handler
37-
bot.on(eventList, (event={}, self, info) => {
37+
bot.on(eventList, (event={}, props, info) => {
3838

3939
// Skip event with "skipReport: true" option key
4040
if (

0 commit comments

Comments
 (0)