parseCtcpCommand :: ByteString -> Maybe (ByteString, ByteString)
parseCtcpCommand msg
  | B8.length msg >= 3
  , B8.head   msg == '\^A'
  , B8.last   msg == '\^A' = Just (B8.map toUpper command, B8.drop 1 rest)
  | otherwise              = Nothing
  where
  sansControls = B8.tail (B8.init msg)
  (command,rest) = B8.break (==' ') sansControls

-- | Record the new topic as set by the given user and
-- emit a change event.
parseCtcpCommand :: ByteString -> Maybe (ByteString, ByteString)
parseCtcpCommand msg
  | B8.length msg >= 3
  , B8.head   msg == '\^A'
  , B8.last   msg == '\^A' = Just (B8.map toUpper command, B8.drop 1 rest)
  | otherwise              = Nothing
  where
  sansControls = B8.tail (B8.init msg)
  (command,rest) = B8.break (==' ') sansControls

-- | Record the new topic as set by the given user and
-- emit a change event.
parseCtcpCommand msg
  | B8.length msg >= 3
  , B8.head   msg == '\^A'
  , B8.last   msg == '\^A' = Just (B8.map toUpper command, B8.drop 1 rest)
  | otherwise              = Nothing
  where
  sansControls = B8.tail (B8.init msg)
  (command,rest) = B8.break (==' ') sansControls

-- | Record the new topic as set by the given user and
-- emit a change event.