Skip to content

Commit

Permalink
jump into another story once unmatch current story loop
Browse files Browse the repository at this point in the history
  • Loading branch information
hyzhak committed Feb 28, 2017
1 parent b8dce52 commit 3c3c1df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 0 additions & 1 deletion botstory/ast/loop_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ def action2_after_part(ctx):


@pytest.mark.asyncio
@pytest.mark.skip
async def test_break_loop_on_unmatched_message_and_jump_to_another_story():
action1_trigger = SimpleTrigger(0)
action3_trigger = SimpleTrigger(0)
Expand Down
14 changes: 11 additions & 3 deletions botstory/ast/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,17 @@ async def match_message(self, message_ctx):
while True:
if ctx.is_empty_stack():
# we have reach the bottom of stack
logger.debug(' we have reach the bottom of stack '
'so no once has receive this message')
return ctx.message
if ctx.does_it_match_any_story():
# but sometimes we could jump on other global matcher
ctx = story_context.reducers.scope_in(ctx)
ctx = await self.process_story(ctx)
ctx = story_context.reducers.scope_out(ctx)
if ctx.is_empty_stack():
return ctx.message
else:
logger.debug(' we have reach the bottom of stack '
'so no once has receive this message')
return ctx.message

if ctx.is_scope_level() and \
(ctx.has_child_story() or ctx.matched) and \
Expand Down

0 comments on commit 3c3c1df

Please sign in to comment.