-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | IRC core library for glirc
--   
--   IRC core library for glirc
--   
--   The glirc client has been split off into
--   <a>https://hackage.haskell.org/package/glirc</a>
@package irc-core
@version 2.3.0


-- | This module implements a simple rate limiter based on the IRC RFC to
--   be used to keep an IRC client from getting disconnected for flooding.
--   It allows one event per duration with a given threshold.
--   
--   This algorithm keeps track of the time at which the client may start
--   sending messages. Each message sent advances that time into the future
--   by the <tt>penalty</tt>. The client is allowed to transmit up to
--   <tt>threshold</tt> seconds ahead of this time.
module Irc.RateLimit

-- | The <a>RateLimit</a> keeps track of rate limit settings as well as the
--   current state of the limit.
data RateLimit

-- | Construct a new rate limit with the given penalty and threshold.
newRateLimit :: Rational -> Rational -> IO RateLimit

-- | Account for an event in the context of a <a>RateLimit</a>. This
--   command will block and delay as required to satisfy the current rate.
--   Once it returns it is safe to proceed with the rate limited action.
tickRateLimit :: RateLimit -> IO ()


-- | This module provides support for interpreting the modes changed by a
--   MODE command.
module Irc.Modes

-- | Settings that describe how to interpret channel modes
data ModeTypes
ModeTypes :: [Char] -> [Char] -> [Char] -> [Char] -> [(Char, Char)] -> ModeTypes

-- | modes for channel lists (e.g. ban)
[_modesLists] :: ModeTypes -> [Char]

-- | modes that always have an argument
[_modesAlwaysArg] :: ModeTypes -> [Char]

-- | modes that have an argument when set
[_modesSetArg] :: ModeTypes -> [Char]

-- | modes that never have arguments
[_modesNeverArg] :: ModeTypes -> [Char]

-- | modes requiring a nickname argument (mode,sigil)
[_modesPrefixModes] :: ModeTypes -> [(Char, Char)]

-- | Lens for <tt>_modesList</tt>
modesLists :: Functor f => ([Char] -> f [Char]) -> ModeTypes -> f ModeTypes

-- | Lens for <a>_modesAlwaysArg</a>
modesAlwaysArg :: Functor f => ([Char] -> f [Char]) -> ModeTypes -> f ModeTypes

-- | Lens for <a>_modesSetArg</a>
modesSetArg :: Functor f => ([Char] -> f [Char]) -> ModeTypes -> f ModeTypes

-- | Lens for <a>_modesNeverArg</a>
modesNeverArg :: Functor f => ([Char] -> f [Char]) -> ModeTypes -> f ModeTypes

-- | Lens for <a>_modesPrefixModes</a>
modesPrefixModes :: Functor f => ([(Char, Char)] -> f [(Char, Char)]) -> ModeTypes -> f ModeTypes

-- | The channel modes used by Freenode
defaultModeTypes :: ModeTypes

-- | The default UMODE used by Freenode
defaultUmodeTypes :: ModeTypes

-- | Split up a mode change command and arguments into individual changes
--   given a configuration.
splitModes :: ModeTypes -> Text -> [Text] -> Maybe [(Bool, Char, Text)]

-- | Construct the arguments to a MODE command corresponding to the given
--   mode changes.
unsplitModes :: [(Bool, Char, Text)] -> [Text]
instance GHC.Show.Show Irc.Modes.ModeTypes


-- | This module defines support for working with IRC's numeric reply
--   codes. Pattern synonyms are provided for each of the possible IRC
--   reply codes.
--   
--   Reply code information was extracted from
--   <a>https://www.alien.net.au/irc/irc2numerics.html</a>
module Irc.Identifier

-- | Identifier representing channels and nicknames
data Identifier

-- | Returns a <a>ByteArray</a> of an <a>Identifier</a> which is suitable
--   for comparison or hashing which has been normalized for case.
idDenote :: Identifier -> ByteArray

-- | Construct an <a>Identifier</a> from a <a>ByteString</a>
mkId :: Text -> Identifier

-- | Returns the original <a>Text</a> of an <a>Identifier</a>
idText :: Identifier -> Text

-- | Returns the case-normalized <a>Text</a> for an identifier.
idTextNorm :: Identifier -> Text

-- | Returns <a>True</a> when the first argument is a prefix of the second.
idPrefix :: Identifier -> Identifier -> Bool
instance GHC.Classes.Eq Irc.Identifier.Identifier
instance GHC.Show.Show Irc.Identifier.Identifier
instance GHC.Read.Read Irc.Identifier.Identifier
instance GHC.Classes.Ord Irc.Identifier.Identifier
instance Data.Hashable.Class.Hashable Irc.Identifier.Identifier
instance Data.String.IsString Irc.Identifier.Identifier


-- | Information identifying users on IRC. This information includes a
--   nickname and optionally a username and hostname.
module Irc.UserInfo

-- | <a>UserInfo</a> packages a nickname along with the username and
--   hsotname if they are known in the current context.
data UserInfo
UserInfo :: {-# UNPACK #-} !Identifier -> {-# UNPACK #-} !Text -> {-# UNPACK #-} !Text -> UserInfo

-- | nickname
[userNick] :: UserInfo -> {-# UNPACK #-} !Identifier

-- | username, empty when missing
[userName] :: UserInfo -> {-# UNPACK #-} !Text

-- | hostname, empty when missing
[userHost] :: UserInfo -> {-# UNPACK #-} !Text

-- | Render <a>UserInfo</a> as <tt>nick!username@hostname</tt>
renderUserInfo :: UserInfo -> Text

-- | Split up a hostmask into a nickname, username, and hostname. The
--   username and hostname might not be defined but are delimited by a
--   <tt>!</tt> and <tt>@</tt> respectively.
parseUserInfo :: Text -> UserInfo

-- | <tt>Lens</tt> into <a>userNick</a> field.
uiNick :: Functor f => (Identifier -> f Identifier) -> UserInfo -> f UserInfo
instance GHC.Show.Show Irc.UserInfo.UserInfo
instance GHC.Read.Read Irc.UserInfo.UserInfo
instance GHC.Classes.Eq Irc.UserInfo.UserInfo


-- | 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.
module Irc.RawIrcMsg

-- | <a>RawIrcMsg</a> 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.
--   
--   This parser is permissive regarding spaces. It aims to parse carefully
--   constructed messages exactly and to make a best effort to recover from
--   extraneous spaces. It makes no effort to validate nicknames,
--   usernames, hostnames, commands, etc. Servers don't all agree on these
--   things.
--   
--   <pre>
--   :prefix COMMAND param0 param1 param2 .. paramN
--   </pre>
data RawIrcMsg
RawIrcMsg :: [TagEntry] -> Maybe UserInfo -> !Text -> [Text] -> RawIrcMsg

-- | IRCv3.2 message tags
[_msgTags] :: RawIrcMsg -> [TagEntry]

-- | Optional sender of message
[_msgPrefix] :: RawIrcMsg -> Maybe UserInfo

-- | command
[_msgCommand] :: RawIrcMsg -> !Text

-- | command parameters
[_msgParams] :: RawIrcMsg -> [Text]

-- | Key value pair representing an IRCv3.2 message tag. The value in this
--   pair has had the message tag unescape algorithm applied.
data TagEntry
TagEntry :: {-# UNPACK #-} !Text -> {-# UNPACK #-} !Text -> TagEntry

-- | Construct a new <a>RawIrcMsg</a> without a time or prefix.
rawIrcMsg :: Text -> [Text] -> RawIrcMsg

-- | Lens for <a>_msgTags</a>
msgTags :: Functor f => ([TagEntry] -> f [TagEntry]) -> RawIrcMsg -> f RawIrcMsg

-- | Lens for <a>_msgPrefix</a>
msgPrefix :: Functor f => (Maybe UserInfo -> f (Maybe UserInfo)) -> RawIrcMsg -> f RawIrcMsg

-- | Lens for <a>_msgCommand</a>
msgCommand :: Functor f => (Text -> f Text) -> RawIrcMsg -> f RawIrcMsg

-- | Lens for <a>_msgParams</a>
msgParams :: Functor f => ([Text] -> f [Text]) -> RawIrcMsg -> f RawIrcMsg

-- | Attempt to split an IRC protocol message without its trailing newline
--   information into a structured message.
parseRawIrcMsg :: Text -> Maybe RawIrcMsg

-- | Serialize a structured IRC protocol message back into its wire format.
--   This command adds the required trailing newline.
renderRawIrcMsg :: RawIrcMsg -> ByteString

-- | Parse a rendered <a>UserInfo</a> token.
prefixParser :: Parser UserInfo

-- | Take the next space-delimited lexeme
simpleTokenParser :: Parser Text

-- | 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.
asUtf8 :: ByteString -> Text
instance GHC.Show.Show Irc.RawIrcMsg.RawIrcMsg
instance GHC.Read.Read Irc.RawIrcMsg.RawIrcMsg
instance GHC.Classes.Eq Irc.RawIrcMsg.RawIrcMsg
instance GHC.Show.Show Irc.RawIrcMsg.TagEntry
instance GHC.Read.Read Irc.RawIrcMsg.TagEntry
instance GHC.Classes.Eq Irc.RawIrcMsg.TagEntry


-- | This module provides smart constructors for IRC commands.
module Irc.Commands

-- | ADMIN command
--   
--   <pre>
--   ADMIN [&lt;target&gt;]
--   </pre>
ircAdmin :: Text -> RawIrcMsg

-- | AWAY command
ircAway :: Text -> RawIrcMsg

-- | CAP END command
ircCapEnd :: RawIrcMsg

-- | CAP LS command
ircCapLs :: RawIrcMsg

-- | CAP REQ command
ircCapReq :: [Text] -> RawIrcMsg

-- | CNOTICE command
--   
--   <pre>
--   CNOTICE &lt;nickname&gt; &lt;channel&gt; :&lt;message&gt;
--   </pre>
ircCnotice :: Text -> Text -> Text -> RawIrcMsg

-- | CPRIVMSG command
--   
--   <pre>
--   CPRIVMSG &lt;nickname&gt; &lt;channel&gt; :&lt;message&gt;
--   </pre>
ircCprivmsg :: Text -> Text -> Text -> RawIrcMsg

-- | INFO command
ircInfo :: RawIrcMsg

-- | INVITE command
ircInvite :: Text -> Identifier -> RawIrcMsg

-- | ISON command
ircIson :: [Text] -> RawIrcMsg

-- | JOIN command
ircJoin :: Text -> Maybe Text -> RawIrcMsg

-- | KICK command
ircKick :: Identifier -> Text -> Text -> RawIrcMsg

-- | KILL command
ircKill :: Text -> Text -> RawIrcMsg

-- | KNOCK command
--   
--   <pre>
--   KNOCK &lt;channel&gt; [&lt;message&gt;]
--   </pre>
ircKnock :: Text -> Text -> RawIrcMsg

-- | LINKS command
ircLinks :: [Text] -> RawIrcMsg

-- | LIST command
ircList :: [Text] -> RawIrcMsg

-- | LUSERS command
--   
--   <pre>
--   LUSERS [&lt;mask&gt; [&lt;server&gt;]]
--   </pre>
ircLusers :: [Text] -> RawIrcMsg

-- | MAP command
ircMap :: RawIrcMsg

-- | MODE command
ircMode :: Identifier -> [Text] -> RawIrcMsg

-- | MOTD command
--   
--   <pre>
--   MOTD [&lt;server&gt;]
--   </pre>
ircMotd :: Text -> RawIrcMsg

-- | NICK command
ircNick :: Text -> RawIrcMsg

-- | NOTICE command
ircNotice :: Text -> Text -> RawIrcMsg

-- | OPER command
ircOper :: Text -> Text -> RawIrcMsg

-- | PART command
ircPart :: Identifier -> Text -> RawIrcMsg

-- | PASS command
ircPass :: Text -> RawIrcMsg

-- | PING command
ircPing :: [Text] -> RawIrcMsg

-- | PONG command
ircPong :: [Text] -> RawIrcMsg

-- | PRIVMSG command
ircPrivmsg :: Text -> Text -> RawIrcMsg

-- | RULES command
ircRules :: Text -> RawIrcMsg

-- | QUIT command
ircQuit :: Text -> RawIrcMsg

-- | REMOVE command
ircRemove :: Identifier -> Text -> Text -> RawIrcMsg

-- | STATS command
ircStats :: [Text] -> RawIrcMsg

-- | TIME command
ircTime :: Text -> RawIrcMsg

-- | TOPIC command
ircTopic :: Identifier -> Text -> RawIrcMsg

-- | USER command
ircUser :: Text -> Bool -> Bool -> Text -> RawIrcMsg

-- | USERHOST command
ircUserhost :: [Text] -> RawIrcMsg

-- | WHO command
ircWho :: [Text] -> RawIrcMsg

-- | WHOIS command
ircWhois :: [Text] -> RawIrcMsg

-- | WHOWAS command
ircWhowas :: [Text] -> RawIrcMsg

-- | VERSION command
ircVersion :: Text -> RawIrcMsg

-- | ZNC command
--   
--   <i>specific to ZNC</i>
ircZnc :: [Text] -> RawIrcMsg

-- | AUTHENTICATE command
ircAuthenticate :: Text -> RawIrcMsg

-- | PLAIN authentiation mode
plainAuthenticationMode :: Text

-- | Encoding of username and password in PLAIN authentication
encodePlainAuthentication :: Text -> Text -> Text


-- | This module defines support for working with IRC's numeric reply
--   codes. Pattern synonyms are provided for each of the possible IRC
--   reply codes.
--   
--   Reply code information was extracted from
--   <a>https://www.alien.net.au/irc/irc2numerics.html</a>
module Irc.Codes

-- | Type of numeric reply codes
newtype ReplyCode
ReplyCode :: Word -> ReplyCode

-- | Shows number

-- | Reads only the number

-- | Categories for reply codes
data ReplyType

-- | 0-99 Messages between client and server
ClientServerReply :: ReplyType

-- | 200-399 Responses to commands
CommandReply :: ReplyType

-- | 400-599 Errors
ErrorReply :: ReplyType

-- | Uncategorized
UnknownReply :: ReplyType

-- | Information describing the category and human decipherable name of a
--   reply.
data ReplyCodeInfo
ReplyCodeInfo :: !ReplyType -> !Text -> ReplyCodeInfo

-- | category
[replyCodeType] :: ReplyCodeInfo -> !ReplyType

-- | human-decipherable name
[replyCodeText] :: ReplyCodeInfo -> !Text

-- | Compute information for a reply code
replyCodeInfo :: ReplyCode -> ReplyCodeInfo

-- | Categorize a reply code using the unknown category and simply showing
--   the reply code's number as its name.
defaultReplyCodeInfo :: Int -> ReplyCodeInfo

-- | Information about reply codes as derived from Freenode's ircd-seven.
replyCodeInfoTable :: Vector ReplyCodeInfo
instance GHC.Read.Read Irc.Codes.ReplyCodeInfo
instance GHC.Show.Show Irc.Codes.ReplyCodeInfo
instance GHC.Classes.Ord Irc.Codes.ReplyCodeInfo
instance GHC.Classes.Eq Irc.Codes.ReplyCodeInfo
instance GHC.Show.Show Irc.Codes.ReplyType
instance GHC.Read.Read Irc.Codes.ReplyType
instance GHC.Classes.Ord Irc.Codes.ReplyType
instance GHC.Classes.Eq Irc.Codes.ReplyType
instance GHC.Classes.Ord Irc.Codes.ReplyCode
instance GHC.Classes.Eq Irc.Codes.ReplyCode
instance GHC.Show.Show Irc.Codes.ReplyCode
instance GHC.Read.Read Irc.Codes.ReplyCode


-- | This module defines high-level IRC commands. Commands are interpreted
--   and their arguments are extracted into the appropriate types.
module Irc.Message

-- | High-level IRC message representation
data IrcMsg

-- | pass-through for unhandled messages
UnknownMsg :: !RawIrcMsg -> IrcMsg

-- | code arguments
Reply :: !ReplyCode -> [Text] -> IrcMsg

-- | old new
Nick :: !UserInfo -> !Identifier -> IrcMsg

-- | user channel
Join :: !UserInfo -> !Identifier -> IrcMsg

-- | user channel reason
Part :: !UserInfo -> !Identifier -> (Maybe Text) -> IrcMsg

-- | user reason
Quit :: !UserInfo -> (Maybe Text) -> IrcMsg

-- | kicker channel kickee comment
Kick :: !UserInfo -> !Identifier -> !Identifier -> !Text -> IrcMsg

-- | user channel topic
Topic :: !UserInfo -> !Identifier -> !Text -> IrcMsg

-- | source target txt
Privmsg :: !UserInfo -> !Identifier -> !Text -> IrcMsg

-- | source target command txt
Ctcp :: !UserInfo -> !Identifier -> !Text -> !Text -> IrcMsg

-- | source target command txt
CtcpNotice :: !UserInfo -> !Identifier -> !Text -> !Text -> IrcMsg

-- | source target txt
Notice :: !UserInfo -> !Identifier -> !Text -> IrcMsg

-- | source target txt
Mode :: !UserInfo -> !Identifier -> [Text] -> IrcMsg

-- | parameters
Authenticate :: !Text -> IrcMsg

-- | command parameters
Cap :: !CapCmd -> [Text] -> IrcMsg

-- | parameters
Ping :: [Text] -> IrcMsg

-- | parameters
Pong :: [Text] -> IrcMsg

-- | message
Error :: !Text -> IrcMsg

-- | reference-id type parameters
BatchStart :: Text -> Text -> [Text] -> IrcMsg

-- | reference-id
BatchEnd :: Text -> IrcMsg

-- | Sub-commands of the CAP command
data CapCmd

-- | request list of supported caps
CapLs :: CapCmd

-- | request list of active caps
CapList :: CapCmd

-- | request activation of cap
CapReq :: CapCmd

-- | request accepted
CapAck :: CapCmd

-- | request denied
CapNak :: CapCmd

-- | end negotiation
CapEnd :: CapCmd

-- | Interpret a low-level <a>RawIrcMsg</a> as a high-level <a>IrcMsg</a>.
--   Messages that can't be understood are wrapped in <a>UnknownMsg</a>.
cookIrcMsg :: RawIrcMsg -> IrcMsg

-- | Targets used to direct a message to a window for display
data MessageTarget

-- | Metadata update for a user
TargetUser :: !Identifier -> MessageTarget

-- | Directed message to channel or from user
TargetWindow :: !Identifier -> MessageTarget

-- | Network-level message
TargetNetwork :: MessageTarget

-- | Completely hidden message
TargetHidden :: MessageTarget

-- | Text representation of an IRC message to be used for matching with
--   regular expressions.
ircMsgText :: IrcMsg -> Text

-- | Target information for the window that could be appropriate to display
--   this message in.
msgTarget :: Identifier -> IrcMsg -> MessageTarget

-- | <a>UserInfo</a> of the user responsible for a message.
msgActor :: IrcMsg -> Maybe UserInfo

-- | Split a nick into text parts group by whether or not those parts are
--   valid nickname characters.
nickSplit :: Text -> [Text]

-- | Maximum length computation for the message part for privmsg and
--   notice. Note that the need for the limit is because the server will
--   limit the length of the message sent out to each client, not just the
--   length of the messages it will recieve.
--   
--   Note that the length is on the *encoded message* which is UTF-8 The
--   calculation isn't using UTF-8 on the userinfo part because I'm
--   assuming that the channel name and userinfo are all ASCII
--   
--   <pre>
--   :my!user@info PRIVMSG #channel :messagebodyrn
--   </pre>
computeMaxMessageLength :: UserInfo -> Text -> Int
instance GHC.Show.Show Irc.Message.IrcMsg
instance GHC.Classes.Ord Irc.Message.CapCmd
instance GHC.Classes.Eq Irc.Message.CapCmd
instance GHC.Show.Show Irc.Message.CapCmd
