Ad

Frank like withdrawing a message after he sent it on a chatting channel. If the message is useful, Frank will withdraw it, while he will leave the unimportant message along.

So we need to write a bot to prevent Frank from withdrawing a message. If Frank withdraw something after saying it:

Frank: This message is useful!
Frank: Recalled a message

the bot should display(return) what Frank withdraw:

bot: Frank: This message is useful!

If Frank say something without withdrawing it:

Frank: I will not withdraw this message

the bot should not display anything:

module Kata (bot) where


bot :: String -> String
bot txt
  | length msgs < 2 = ""
  | head msgs == "Frank: Recalled a message" = "bot: " ++ (msgs !! 1)
  | otherwise = ""
  where msgs = reverse $ lines txt