Fix args being empty

This commit is contained in:
Mahdi Dibaiee 2015-07-09 16:07:08 +04:30
parent a9473d1ee8
commit f88927e970
3 changed files with 10 additions and 3 deletions

View File

@ -202,6 +202,8 @@ var Bot = (function (_EventEmitter) {
this.update.offset += 1; this.update.offset += 1;
} }
console.log(update);
update.forEach(function (res) { update.forEach(function (res) {
var marked3$0 = [getAnswer].map(regeneratorRuntime.mark); var marked3$0 = [getAnswer].map(regeneratorRuntime.mark);
@ -237,10 +239,14 @@ var Bot = (function (_EventEmitter) {
var params = _ev$parse.params; var params = _ev$parse.params;
var args = _ev$parse.args; var args = _ev$parse.args;
res.message.args = args;
var requiredParams = Object.keys(params).filter(function (param) { var requiredParams = Object.keys(params).filter(function (param) {
return params[param] === REQUIRED && !args[param]; return params[param] === REQUIRED && !args[param];
}); });
console.log(requiredParams);
if (!requiredParams.length) { if (!requiredParams.length) {
ev.listener(res.message); ev.listener(res.message);
return; return;
@ -337,7 +343,6 @@ var Bot = (function (_EventEmitter) {
(function loop() { (function loop() {
var next = iterator.next(); var next = iterator.next();
if (next.done) { if (next.done) {
res.message.args = args;
ev.listener(res.message); ev.listener(res.message);
return; return;
} }

View File

@ -148,6 +148,8 @@ export default class Bot extends EventEmitter {
this.update.offset += 1; this.update.offset += 1;
} }
console.log(update);
update.forEach(res => { update.forEach(res => {
let text = res.message.text; let text = res.message.text;
if (!text) return; if (!text) return;
@ -174,6 +176,7 @@ export default class Bot extends EventEmitter {
} }
let {params, args} = ev.parse(res.message.text); let {params, args} = ev.parse(res.message.text);
res.message.args = args;
const requiredParams = Object.keys(params).filter(param => { const requiredParams = Object.keys(params).filter(param => {
return params[param] === REQUIRED && !args[param]; return params[param] === REQUIRED && !args[param];
@ -199,7 +202,6 @@ export default class Bot extends EventEmitter {
(function loop() { (function loop() {
const next = iterator.next(); const next = iterator.next();
if (next.done) { if (next.done) {
res.message.args = args;
ev.listener(res.message); ev.listener(res.message);
return; return;
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "telegram-api", "name": "telegram-api",
"version": "0.5.10", "version": "0.5.11",
"description": "Control Telegram bots easily using the new Telegram API", "description": "Control Telegram bots easily using the new Telegram API",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {