-- 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 -- https://hackage.haskell.org/package/glirc @package irc-core @version 2.0.0.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 penalty. The client is allowed to transmit up to -- threshold seconds ahead of this time. module Irc.RateLimit -- | The RateLimit 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 RateLimit. 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)] modesLists :: Lens' ModeTypes [Char] modesAlwaysArg :: Lens' ModeTypes [Char] modesSetArg :: Lens' ModeTypes [Char] modesNeverArg :: Lens' ModeTypes [Char] modesPrefixModes :: Lens' ModeTypes [(Char, Char)] -- | 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 -- https://www.alien.net.au/irc/irc2numerics.html module Irc.Identifier -- | Identifier representing channels and nicknames data Identifier -- | Returns the case-normalized ByteString of an Identifier -- which is suitable for comparison or hashing. idDenote :: Identifier -> Vector Word8 -- | Construct an Identifier from a ByteString mkId :: Text -> Identifier -- | Returns the original Text of an Identifier idText :: Identifier -> Text -- | Returns True when the first argument is a prefix of the second. idPrefix :: Identifier -> Identifier -> Bool instance GHC.Show.Show Irc.Identifier.Identifier instance GHC.Read.Read Irc.Identifier.Identifier instance GHC.Classes.Eq Irc.Identifier.Identifier instance GHC.Classes.Ord Irc.Identifier.Identifier instance Data.Hashable.Class.Hashable Irc.Identifier.Identifier -- | Information identifying users on IRC. This information includes a -- nickname and optionally a username and hostname. module Irc.UserInfo -- | UserInfo 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 UserInfo as nick!username@hostname 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 -- ! and @ respectively. parseUserInfo :: Text -> UserInfo -- | Lens into userNick field. uiNick :: Lens' UserInfo Identifier instance GHC.Show.Show Irc.UserInfo.UserInfo instance GHC.Read.Read 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 -- | 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. -- -- 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. -- --
--   :prefix COMMAND param0 param1 param2 .. paramN
--   
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 RawIrcMsg without a time or prefix. rawIrcMsg :: Text -> [Text] -> RawIrcMsg msgTags :: Lens' RawIrcMsg [TagEntry] msgPrefix :: Lens' RawIrcMsg (Maybe UserInfo) msgCommand :: Lens' RawIrcMsg Text msgParams :: Lens' RawIrcMsg [Text] -- | 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 UserInfo 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.Show.Show Irc.RawIrcMsg.TagEntry instance GHC.Read.Read Irc.RawIrcMsg.TagEntry -- | This module provides smart constructors for IRC commands. module Irc.Commands -- | AWAY command ircAway :: Text -> RawIrcMsg -- | CAP END command ircCapEnd :: RawIrcMsg -- | CAP LS command ircCapLs :: RawIrcMsg -- | CAP REQ command ircCapReq :: [Text] -> 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 -- | LINKS command ircLinks :: [Text] -> RawIrcMsg -- | MODE command ircMode :: Identifier -> [Text] -> RawIrcMsg -- | NICK command ircNick :: Identifier -> RawIrcMsg -- | NOTICE command ircNotice :: Identifier -> 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 :: Identifier -> 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 -- | ZNC command -- -- specific to ZNC 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 -- https://www.alien.net.au/irc/irc2numerics.html module Irc.Codes -- | Type of numeric reply codes newtype ReplyCode ReplyCode :: Word -> ReplyCode -- | Categories for reply codes data ReplyType -- | 0-99 Messages between client and server ClientServerReply :: ReplyType -- | 200-399 Responses to commands CommandReply :: ReplyType -- | 200-399 Errors ErrorReply :: ReplyType -- | Uncategorized UnknownReply :: ReplyType data ReplyCodeInfo ReplyCodeInfo :: !ReplyType -> !Text -> ReplyCodeInfo [replyCodeType] :: ReplyCodeInfo -> !ReplyType [replyCodeText] :: ReplyCodeInfo -> !Text replyCodeInfo :: ReplyCode -> ReplyCodeInfo defaultReplyCodeInfo :: Int -> ReplyCodeInfo replyCodeInfoTable :: Vector ReplyCodeInfo instance GHC.Show.Show 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 -- | 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 RawIrcMsg as a high-level IrcMsg. -- Messages that can't be understood are wrapped in UnknownMsg. 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 -- | UserInfo 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 -- --
--   :my!user@info PRIVMSG #channel :messagebodyrn
--   
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