module M_opssau where

import Mdl


opssau :: String -> String -> Mdl
opssau pw chans log = react f
  where
  f (Msg nick _ _ "PRIVMSG" (to:msg:_))
    | cmd == "ops!" && rest == pw && head to == '#' = return ["MODE "++to++" +o "++nick]
    | cmd == "ops!" && rest == pw = return ["MODE "++chans++" +o "++nick]
    | cmd == "ops!" = return ["PRIVMSG "++tgt nick to++" :jaha, deine mudder kriegt ops"]
    | otherwise = return []
    where
    (cmd,rest) = getarg msg
    getarg xs = let (ys,zs)=break (==' ') xs in (ys, dropWhile (==' ') zs)

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