Fix bot not working properly in groups

Change example a little bit
This commit is contained in:
Mahdi Dibaiee
2015-06-29 04:19:09 +04:30
parent 7174ad30b1
commit a8c4c0e33f
8 changed files with 59 additions and 73 deletions

View File

@ -99,7 +99,6 @@ var Bot = (function (_EventEmitter) {
_this.update.offset += 1;
}
_this.emit('update', response.result);
result.forEach(function (res) {
var text = res.message.text;
if (text.startsWith('/')) {
@ -112,8 +111,10 @@ var Bot = (function (_EventEmitter) {
var pattern = _ref.pattern;
return pattern.test(text);
});
ev.listener(res);
ev.listener(res.message);
});
_this.emit('update', result);
});
}).bind(this);

View File

@ -111,6 +111,8 @@ var Message = (function (_Base) {
value: function send(bot) {
var _this = this;
console.log('sending message');
var messageId = undefined;
var reply_markup = JSON.stringify(this._keyboard.getProperties());
this.properties.reply_markup = reply_markup;

View File

@ -80,8 +80,7 @@ var Question = (function (_Message) {
var answers = this.answers;
return new Promise(function (resolve, reject) {
_get(Object.getPrototypeOf(Question.prototype), 'send', _this).call(_this, bot).then(function (update) {
var message = update.message;
_get(Object.getPrototypeOf(Question.prototype), 'send', _this).call(_this, bot).then(function (message) {
var answer = undefined;
answers.forEach(function find(a) {