glirc2

Copyright(c) Eric Mertens, 2016
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellNone
LanguageHaskell2010

Irc.RawIrcMsg

Contents

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.

Synopsis

Low-level IRC messages

data RawIrcMsg Source #

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

rawIrcMsg Source #

Arguments

:: Text

command

-> [Text]

parameters

-> RawIrcMsg 

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.