update README and demo.js

This commit is contained in:
Mahdi Dibaiee 2015-06-29 05:31:41 +04:30
parent 714ffa9458
commit 4ac725ea58
4 changed files with 8 additions and 6 deletions

View File

@ -24,8 +24,8 @@ var bot = new Bot({
token: 'YOUR_KEY' token: 'YOUR_KEY'
}); });
bot.start().then(() => { bot.start().catch(err => {
console.log(bot.info); console.error(err, '\n', err.stack);
}); });
// polling // polling
@ -44,7 +44,7 @@ bot.get(/Hi\sBot/, message => {
question.to(id).reply(message.message_id); question.to(id).reply(message.message_id);
bot.send(question).then(answer => { bot.send(question).then(answer => {
const msg = new Message().to(id).text('Your answer: ' + answer); const msg = new Message().to(id).text('Your answer: ' + answer.text);
bot.send(msg); bot.send(msg);
}, () => { }, () => {
const msg = new Message().to(id).text('Invalid answer'); const msg = new Message().to(id).text('Invalid answer');

View File

@ -47,7 +47,9 @@ function fetch(path, data) {
req.write(post); req.write(post);
} }
req.end(); req.end();
})['catch'](console.error); })['catch'](function (err) {
console.error('Error sending request', err);
});
} }
module.exports = exports['default']; module.exports = exports['default'];

View File

@ -148,7 +148,7 @@ var Message = (function (_Base) {
bot.removeListener('update', listener); bot.removeListener('update', listener);
} }
}); });
})['catch'](console.error); });
} }
}]); }]);

View File

@ -5,7 +5,7 @@ var Message = require('telegram-api/types/Message');
var Question = require('telegram-api/types/Question'); var Question = require('telegram-api/types/Question');
var bot = new Bot({ var bot = new Bot({
token: '121143906:AAE6pcpBoARNZZjr3fUpvKuLInJ5Eee5Ajk' token: 'YOUR_KEY'
}); });
bot.start().catch(err => { bot.start().catch(err => {