| Copyright | (c) Eric Mertens, 2016 |
|---|---|
| License | ISC |
| Maintainer | emertens@gmail.com |
| Safe Haskell | None |
| Language | Haskell2010 |
Irc.RawIrcMsg
Description
This module provides a parser and printer for the low-level IRC message format. It handles splitting up IRC commands into the prefix, command, and arguments.
- data RawIrcMsg = RawIrcMsg {
- _msgServerTime :: Maybe UTCTime
- _msgPrefix :: Maybe UserInfo
- _msgCommand :: Text
- _msgParams :: [Text]
- rawIrcMsg :: Text -> [Text] -> RawIrcMsg
- msgServerTime :: Lens' RawIrcMsg (Maybe UTCTime)
- msgPrefix :: Lens' RawIrcMsg (Maybe UserInfo)
- msgCommand :: Lens' RawIrcMsg Text
- msgParams :: Lens' RawIrcMsg [Text]
- parseRawIrcMsg :: Text -> Maybe RawIrcMsg
- renderRawIrcMsg :: RawIrcMsg -> ByteString
- asUtf8 :: ByteString -> Text
Low-level IRC messages
RawIrcMsg breaks down the IRC protocol into its most basic parts.
The "trailing" parameter indicated in the IRC protocol with a leading
colon will appear as the last parameter in the parameter list.
Note that RFC 2812 specifies a maximum of 15 parameters.
:prefix COMMAND param0 param1 param2 .. paramN
Constructors
| RawIrcMsg | |
Fields
| |
Construct a new RawIrcMsg without a time or prefix.
Text format for IRC messages
parseRawIrcMsg :: Text -> Maybe RawIrcMsg Source #
Attempt to split an IRC protocol message without its trailing newline information into a structured message.
renderRawIrcMsg :: RawIrcMsg -> ByteString Source #
Take the bytes up to the next space delimiter.
If the first character of this token is a :
then take the whole remaining bytestring
Serialize a structured IRC protocol message back into its wire format. This command adds the required trailing newline.
Permissive text decoder
asUtf8 :: ByteString -> Text Source #
Try to decode a message as UTF-8. If that fails interpret it as Windows CP1252 This helps deal with clients like XChat that get clever and otherwise misconfigured clients.