Commit 260fc78b authored by Nicolas Lenz's avatar Nicolas Lenz

Implement mocking as command reply

parent a6d607c9
Pipeline #141 passed with stage
in 1 minute and 41 seconds
......@@ -51,12 +51,18 @@ directMock = UpdateParser f where
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:body') = T.splitOn " " txt
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
Just f -> return $ f (T.unwords body)
Just f -> if T.null body
then do
replyToMessage <- Telegram.messageReplyToMessage message
replyToText <- Telegram.messageText replyToMessage
return $ f replyToText
else return $ f body
_ -> if isPrivate message then return "Invalid mocking. See /help." else fail "Invalid mocking."
replyToInline :: UpdateParser [(Text, Text, Text)]
......
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