Commit e535c749 authored by Nicolas Lenz's avatar Nicolas Lenz

Fix directMock

parent bcac7887
Pipeline #143 passed with stage
in 1 minute and 47 seconds
......@@ -18,6 +18,8 @@ import Control.Monad.Reader
import Text.Mock
import Text.Mock.Help (styleHelp)
import System.IO.Unsafe
-- | Bot conversation state model.
data Model = Model deriving (Show)
......@@ -49,12 +51,9 @@ directMock = UpdateParser f where
f :: Telegram.Update -> Maybe Text
f update = do
message <- Telegram.updateMessage update
txt' <- Telegram.messageText message
let txt = if T.head txt' == '/' then T.tail txt' else txt'
let (command':body') = T.splitOn " " txt
let (command, _) = T.breakOn "@" command
(command':body') <- T.words <$> Telegram.messageText message
let styleNames = T.splitOn "|" . T.toLower $ fst $ T.breakOn "@" $ if T.head command' == '/' then T.tail command' else command'
let body = T.unwords body'
let styleNames = T.splitOn "|" . T.toLower $ command
if length styleNames > 5 then
return "Only concatenations of up to 5 styles are allowed."
else case concatMaybeFunctions . map (`lookup` styles) $ styleNames of
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment