module Lambdabot.Plugin.Novelty.Unlambda (unlambdaPlugin) where
import Lambdabot.Config.Novelty
import Lambdabot.Plugin
import Lambdabot.Util.Process
import Text.Regex.TDFA
unlambdaPlugin :: Module ()
unlambdaPlugin = newModule
{ moduleCmds = return
[ (command "unlambda")
{ help = say "unlambda <expr>. Evaluate an unlambda expression"
, process = \msg -> do
binary <- getConfig unlambdaBinary
ios80 (run binary msg scrub)
}
]
}
scrub :: String -> String
scrub = unlines . take 6 . map (' ':) . lines . cleanit
cleanit :: String -> String
cleanit s | s =~ terminated = "Terminated\n"
| otherwise = s
where terminated = "waitForProc"