lambdabot-utils-4.2.2: Utility libraries for the advanced IRC bot, Lambdabot

Safe HaskellNone



URL Utility Functions



getHtmlPage :: URI -> WebReq [String]Source

Fetch the contents of a URL following HTTP redirects. It returns a list of strings comprising the server response which includes the status line, response headers, and body.

getHeader :: String -> [String] -> Maybe StringSource

Retrieve the specified header from the server response being careful to strip the trailing carriage return. I swiped this code from Search.hs, but had to modify it because it was not properly stripping off the trailing CR (must not have manifested itself as a bug in that code; however, parseURI will fail against CR-terminated strings.

rawPageTitle :: String -> WebReq (Maybe String)Source

Fetches a page title for the specified URL. This function should only be used by other plugins if and only if the result is not to be displayed in an IRC channel. Instead, use urlPageTitle.

urlPageTitle :: String -> WebReq (Maybe String)Source

Fetches a page title suitable for display. Ideally, other plugins should make use of this function if the result is to be displayed in an IRC channel because it ensures that a consistent look is used (and also lets the URL plugin effectively ignore contextual URLs that might be generated by another instance of lambdabot; the URL plugin matches on urlTitlePrompt).

urlTitlePrompt :: StringSource

The string that I prepend to the quoted page title.

runWebReq :: WebReq a -> Proxy -> IO aSource