-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell interface for antigate.com captcha recognition service, and other services which support its API. -- -- Haskell interface for antigate.com captcha recognition service, and -- other services which support its API (e.g. captchabot, decaptcher). @package antigate @version 0.3 -- | Example: -- --
--   import Text.Recognition.Antigate
--   import Data.Default
--   import Network
--   import Control.Monad
--   import Control.Monad.IO.Class
--   import Data.ByteString.Lazy hiding (putStrLn)
--   import System.Timeout
--   
--   myApiKey :: ApiKey
--   myApiKey = "0123456789abcdef0123456789abcdef"
--   
--   downloadJpegCaptcha :: Manager -> IO ByteString
--   downloadJpegCaptcha = undefined
--   
--   answerCaptcha :: String -> Manager -> IO Bool
--   answerCaptcha = undefined
--   
--   main :: IO ()
--   main = withSocketsDo $ do
--       res <- timeout (30*1000000) $ withManager $ \m -> do
--           bytes <- liftIO $ downloadJpegCaptcha m
--           (id, answer) <- solveCaptcha def myApiKey def{phrase=True} "captcha.jpg" bytes m
--           res <- liftIO $ answerCaptcha answer m
--           unless res $ reportBad myApiKey id m
--           return res
--       case res of
--           Nothing -> do
--               putStrLn "Timed out"
--           Just True -> do
--               putStrLn "Solved successfully"
--           Just False -> do
--               putStrLn "Couldn't solve"
--   
module Text.Recognition.Antigate -- | Antigate API access key paired with service provider's host. At least -- these services claim to support Antigate API: Antigate, Captchabot, -- Decaptcher, ExpertDecoders, ImageTyperz, DeathByCaptcha and Pixodrom. data ApiKey ApiKey :: String -> String -> ApiKey -- | default: "antigate.com" api_host :: ApiKey -> String api_key :: ApiKey -> String type CaptchaID = Int -- | Properties of the captcha to be solved. See -- http://antigate.com/panel.php?action=api data CaptchaConf CaptchaConf :: Bool -> Bool -> Maybe Bool -> Bool -> Word -> Word -> Bool -> Maybe Double -> CaptchaConf -- | phrase :: CaptchaConf -> Bool -- | regsense :: CaptchaConf -> Bool -- | numeric :: CaptchaConf -> Maybe Bool -- | calc :: CaptchaConf -> Bool -- | min_len :: CaptchaConf -> Word -- | max_len :: CaptchaConf -> Word -- | is_russian :: CaptchaConf -> Bool -- | Default value is set on bids page. This parameter allows to -- control maximum bid without setting it on the bids page. max_bid :: CaptchaConf -> Maybe Double data UploadResult -- | result is positive, your captcha is accepted for recognition and its -- ID follows. You may now attempt to retrieve captcha status with this -- ID. UPLOAD_OK :: CaptchaID -> UploadResult -- | user authorization key is invalid (its length is not 32 bytes as it -- should be) ERROR_WRONG_USER_KEY :: UploadResult -- | you have set wrong user authorization key in request UPLOAD_ERROR_KEY_DOES_NOT_EXIST :: UploadResult -- | account has zero or negative balance ERROR_ZERO_BALANCE :: UploadResult -- | no idle captcha workers are available at the moment, please try a bit -- later or try increasing your bid ERROR_NO_SLOT_AVAILABLE :: UploadResult -- | the size of the captcha you are uploading or pointing to is zero ERROR_ZERO_CAPTCHA_FILESIZE :: UploadResult -- | your captcha size is exceeding 100kb limit ERROR_TOO_BIG_CAPTCHA_FILESIZE :: UploadResult -- | your captcha file has wrong extension, the only allowed extensions are -- gif,jpg,jpeg,png ERROR_WRONG_FILE_EXTENSION :: UploadResult -- | Could not determine captcha file type, only allowed formats are JPG, -- GIF, PNG ERROR_IMAGE_TYPE_NOT_SUPPORTED :: UploadResult -- | Request with current account key is not allowed from your IP. Please -- refer to IP list section ERROR_IP_NOT_ALLOWED :: UploadResult UPLOAD_ERROR_UNKNOWN :: String -> UploadResult data CheckResult -- | the captcha is recognized, the guessed text follows CHECK_OK :: String -> CheckResult -- | captcha is not recognized yet, repeat request withing 1-5 seconds CAPCHA_NOT_READY :: CheckResult -- | you have set wrong user authorization key in request CHECK_ERROR_KEY_DOES_NOT_EXIST :: CheckResult -- | the captcha ID you are sending is non-numeric ERROR_WRONG_ID_FORMAT :: CheckResult CHECK_ERROR_UNKNOWN :: String -> CheckResult data SolveException SolveExceptionUpload :: UploadResult -> SolveException SolveExceptionCheck :: CaptchaID -> CheckResult -> SolveException data SolveConf SolveConf :: Int -> Int -> (Phase -> IO ()) -> SolveConf -- | how much to sleep while waiting for available slot. Microseconds. api_upload_sleep :: SolveConf -> Int -- | how much to sleep between captcha checks. Microseconds. api_check_sleep :: SolveConf -> Int -- | This action will be executed before each sleep. e.g. print api_counter :: SolveConf -> Phase -> IO () data Phase UploadPhase :: Phase CheckPhase :: Phase -- | High level function to solve captcha, blocks until answer is provided -- (about 2-10 seconds). -- -- throws SolveException or HttpException when something -- goes wrong. solveCaptcha :: MonadResource m => SolveConf -> ApiKey -> CaptchaConf -> FilePath -> ByteString -> Manager -> m (CaptchaID, String) solveCaptchaFromFile :: (MonadBaseControl IO m, MonadResource m) => SolveConf -> ApiKey -> CaptchaConf -> FilePath -> Manager -> m (CaptchaID, String) -- | upload captcha for recognition -- -- throws HttpException on network errors. uploadCaptcha :: MonadResource m => ApiKey -> CaptchaConf -> FilePath -> ByteString -> Manager -> m UploadResult uploadCaptchaFromFile :: MonadResource m => ApiKey -> CaptchaConf -> FilePath -> Manager -> m UploadResult -- | retrieve captcha status -- -- throws HttpException on network errors. checkCaptcha :: MonadResource m => ApiKey -> CaptchaID -> Manager -> m CheckResult -- | retrieve multiple captcha status -- -- throws HttpException on network errors. checkCaptchas :: MonadResource m => ApiKey -> [CaptchaID] -> Manager -> m [CheckResult] -- | report bad captcha result -- -- throws HttpException on network errors. reportBad :: MonadResource m => ApiKey -> CaptchaID -> Manager -> m () -- | retrieve your current account balance -- -- throws HttpException on network errors. getBalance :: MonadResource m => ApiKey -> Manager -> m Double -- | Keeps track of open connections for keep-alive. If possible, you -- should share a single Manager between multiple threads and -- requests. data Manager :: * -- | Create a Manager. You must manually call closeManager to -- shut it down. -- -- Creating a new Manager is an expensive operation, you are -- advised to share a single Manager between requests instead. newManager :: ManagerSettings -> IO Manager -- | Close all connections in a Manager. Afterwards, the -- Manager can be reused if desired. closeManager :: Manager -> IO () -- | Create a new manager, use it in the provided function, and then -- release it. -- -- This function uses the default manager settings. For more control, use -- withManagerSettings. withManager :: (MonadIO m, MonadBaseControl IO m, MonadThrow m, MonadUnsafeIO m) => (Manager -> ResourceT m a) -> m a -- | Parse antigate's upload response parseUploadResult :: String -> UploadResult -- | Parse antigate's check response parseCheckResult :: String -> CheckResult -- | Parse antigate's multi-check response parseCheckResults :: String -> [CheckResult] -- | Parse antigate's multi-check response parseCheckResultNoOK :: String -> CheckResult -- | Marshal UploadResult back to its text form renderUploadResult :: UploadResult -> String -- | Marshal CheckResult back to its text form renderCheckResult :: CheckResult -> String instance Typeable SolveException instance Eq ApiKey instance Ord ApiKey instance Show ApiKey instance Read ApiKey instance Show CaptchaConf instance Read CaptchaConf instance Show UploadResult instance Read UploadResult instance Eq UploadResult instance Ord UploadResult instance Show CheckResult instance Read CheckResult instance Eq CheckResult instance Ord CheckResult instance Show SolveException instance Show Phase instance Read Phase instance Eq Phase instance Ord Phase instance Enum Phase instance Bounded Phase instance Show SolveConf instance Default SolveConf instance Exception SolveException instance Default CaptchaConf instance IsString ApiKey instance Default ApiKey