Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
This module provides functions for creating and encoding messages for use within Pushover requests.
Pushover messages contain a very limited subset of HTML. Users can insert bold,
italic, underlined, and colored text, and URLs within messages. The Message
type represents all of these possible formatting options.
Constructing a Message
is done through the use of the message
, bold
,
italic
, underline
, color
, link
, and text
functions. The message
function takes a list of parts created using the other functions, and
concatenates these into a single message. Different types of formatting can
be nested within each other by simply calling the functions on the results of
other function calls. For example:-
bold [ italic [ text "This is bold & italic" ] , text "This is bold" , underline [ text "This is bold & underlined" ] ]
will create a message with the text values formatted as described.
- data Message
- message :: [Message] -> Message
- bold :: [Message] -> Message
- italic :: [Message] -> Message
- underline :: [Message] -> Message
- color :: Integer -> Integer -> Integer -> [Message] -> Message
- link :: Url -> [Message] -> Message
- text :: Text -> Message
- encodeMessage :: Message -> ByteString
- data ColorCode
- makeColorCode :: Integer -> Integer -> Integer -> ColorCode
- type Url = Text
Creating a Message
Represents a message sent to the Pushover API.
A Pushover message can be constructed with a very small subset of HTML. This type represents the available HTML formatting for a message.
color :: Integer -> Integer -> Integer -> [Message] -> Message Source #
Make a message with colored text.
Accepts three integer arguments for red, green and blue color elements, respectively.
Encoding for inclusion in request
encodeMessage :: Message -> ByteString Source #
Attributes
Represents an HTML color code.
A ColorCode consists of a red, a green and a blue element, each of which
must have a value of between 0 and 255. This type cannot enforce this
constraint, but see makeColorCode
which does.
makeColorCode :: Integer -> Integer -> Integer -> ColorCode Source #
Construct a ColorCode
value.
A ColorCode
requires a red, a green and a blue value for construction.
This function takes these as arguments and returns a constructed
ColorCode
.
This function checks that each element is within the required 0-255 range. Any element which is not is rounded to the nearest extrema (0 for negative values; 255 for values larger than that number).