Skip to content

Commit

Permalink
Only skip option's answer if is undefined. FIX #131
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelverger committed Jun 6, 2018
1 parent 1814927 commit b489943
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function runActions(bot: YveBot, rule: IRule, prop: string): Promise<any> {
}

function getNextFromRule(rule: IRule, answer?: Answer | Answer[]): RuleNext | null {
if (rule.options.length && answer) {
if (rule.options.length && answer !== undefined) {
const option = utils.findOptionByAnswer(rule.options, answer);
if (option && option.next) {
return option.next;
Expand Down Expand Up @@ -290,6 +290,7 @@ export class Controller {

public jumpByName(ruleName: string): Promise<this> {
const idx = this._indexes[ruleName];
console.log(idx);
if (typeof idx !== 'number') {
throw new this.bot.exceptions.RuleNotFound(ruleName, this._indexes);
}
Expand All @@ -299,6 +300,7 @@ export class Controller {
public nextRule(currentRule: IRule, answer?: Answer | Answer[]): this {
const { bot } = this;
const nextRuleName = getNextFromRule(currentRule, answer);
console.log(nextRuleName);
if (nextRuleName) {
let ruleName;
if (/flow:/.test(nextRuleName)) { // jump to flow
Expand Down

0 comments on commit b489943

Please sign in to comment.