doPrivMsg ::
  UserInfo   {- ^ sender         -} ->
  Identifier {- ^ message target -} ->
  ByteString {- ^ message        -} ->
  IrcConnection -> Logic IrcConnection
doPrivMsg who chan msg conn =
  do stamp <- getStamp
     let (statusmsg, chan') = splitStatusMsg chan conn
         modes = view (connChannels . ix chan' . chanUsers . ix (userNick who)) conn
         mesg = defaultIrcMessage
                { _mesgType    = ty
                , _mesgSender  = who
                , _mesgStamp   = stamp
                , _mesgStatus  = statusmsg
                , _mesgModes   = modes
                }
         ty = case parseCtcpCommand msg of
                Nothing                 -> PrivMsgType (asUtf8 msg)
                Just ("ACTION", action) -> ActionMsgType (asUtf8 action)
                Just (command , args  ) -> CtcpReqMsgType command args

     recordMessage mesg chan' conn
doPrivMsg ::
  UserInfo   {- ^ sender         -} ->
  Identifier {- ^ message target -} ->
  ByteString {- ^ message        -} ->
  IrcConnection -> Logic IrcConnection
doPrivMsg who chan msg conn =
  do stamp <- getStamp
     let (statusmsg, chan') = splitStatusMsg chan conn
         modes = view (connChannels . ix chan' . chanUsers . ix (userNick who)) conn
         mesg = defaultIrcMessage
                { _mesgType    = ty
                , _mesgSender  = who
                , _mesgStamp   = stamp
                , _mesgStatus  = statusmsg
                , _mesgModes   = modes
                }
         ty = case parseCtcpCommand msg of
                Nothing                 -> PrivMsgType (asUtf8 msg)
                Just ("ACTION", action) -> ActionMsgType (asUtf8 action)
                Just (command , args  ) -> CtcpReqMsgType command args

     recordMessage mesg chan' conn
doPrivMsg who chan msg conn =
  do stamp <- getStamp
     let (statusmsg, chan') = splitStatusMsg chan conn
         modes = view (connChannels . ix chan' . chanUsers . ix (userNick who)) conn
         mesg = defaultIrcMessage
                { _mesgType    = ty
                , _mesgSender  = who
                , _mesgStamp   = stamp
                , _mesgStatus  = statusmsg
                , _mesgModes   = modes
                }
         ty = case parseCtcpCommand msg of
                Nothing                 -> PrivMsgType (asUtf8 msg)
                Just ("ACTION", action) -> ActionMsgType (asUtf8 action)
                Just (command , args  ) -> CtcpReqMsgType command args

     recordMessage mesg chan' conn