Commit a6d607c9 authored by Nicolas Lenz's avatar Nicolas Lenz ❄️
Browse files

Refactor directMock

parent 902399ba
Loading
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -49,12 +49,14 @@ directMock = UpdateParser f where
    f :: Telegram.Update -> Maybe Text
    f update = do
        message <- Telegram.updateMessage update
        txt <- Telegram.messageText message
        let styleNames = T.splitOn "|" . T.toLower . head . T.words $ txt
        txt' <- Telegram.messageText message
        let txt = if T.head txt' == '/' then T.tail txt' else txt'
        let (command:body) = T.splitOn " " txt
        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 (\s -> lookup s styles) $ styleNames of
            Just f -> return $ f (T.unwords $ tail $ T.words txt)
        else case concatMaybeFunctions . map (`lookup` styles) $ styleNames of
            Just f -> return $ f (T.unwords body)
            _ -> if isPrivate message then return "Invalid mocking. See /help." else fail "Invalid mocking."

replyToInline :: UpdateParser [(Text, Text, Text)]
+4 −4
Original line number Diff line number Diff line
@@ -12,12 +12,12 @@ packages:
    version: 3.6.0
    git: https://git.eisfunke.com/software/mock
    pantry-tree:
      size: 673
      sha256: 35e4555fb8dbb442548d960a9e3a88e06056e8d221a26ec49d03e207f384fb27
    commit: 1a07d08f679de0ff3420d19d7d1cf3e9499db182
      size: 728
      sha256: 2f23b107d7dffe660f31a2f03b28c414eeeb026db123e7fc506eb10cdc4d8273
    commit: 54dabde276fcb6b341e646d0ce212560baf670fa
  original:
    git: https://git.eisfunke.com/software/mock
    commit: 1a07d08f679de0ff3420d19d7d1cf3e9499db182
    commit: 54dabde276fcb6b341e646d0ce212560baf670fa
- completed:
    cabal-file:
      size: 3398