Skip to content

Commit

Permalink
Ignore bodies of text beginning with session keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
conjunctive committed Nov 17, 2023
1 parent 962e6bb commit 47d14bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions chat-bots-contrib/test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,11 @@ sessionizedBotSpec =
<<<Session '1' Output:
"x" = 42
|]

it "ignores bodies of text beginning with session keywords" $ do
fixBot bot mempty
`conformsToScript` [mkScript|
>>>new body of text that happens to begin with the word new
>>>use body of text that begins with the word use
>>>end body of text that begins with the word end
|]
4 changes: 3 additions & 1 deletion chat-bots/src/Data/Chat/Bot/Context.hs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ sessionizedParser :: (Text -> Maybe i) -> Parser (SessionInput i)
sessionizedParser p = do
keyword <- New <$ "new" <|> Use <$ "use" <|> End <$ "end"
case keyword of
New -> pure StartSession
New -> do
_ <- endOfInput <|> endOfLine
pure StartSession
Use -> do
_ <- space
n <- decimal <* ": "
Expand Down

0 comments on commit 47d14bf

Please sign in to comment.