module M_ceds where

import Mdl
import System.Random


-- current earth destruction status
ceds :: Mdl
ceds log = react f
  where
  f (Msg from _ _ "PRIVMSG" (to:msg:_))
    | map toLower msg =~ "erde (.* )?zerstoert *\\?"
      = do -- machs spannend
           d <- randomRIO (0,3)
	   threadDelay (d * 1000000)
           -- reasonably accurate while the server is on earth
	   -- this NEEDS to be fixed before relocating
           return ["PRIVMSG "++tgt from to++" :Derzeitiger Erdzustand: NICHT zerstoert"]

  tgt from to = if isAlpha (head to) then from else to
