Loading app/Main.hs +4 −5 Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -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 Loading Loading
app/Main.hs +4 −5 Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -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 Loading