Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module implements a high-level view of the state of
the IRC connection. The library user calls advanceModel
to
step the IrcConnection
as new messages arrive.
- data IrcConnection = IrcConnection {
- _connNick :: !Identifier
- _connChannels :: !(Map Identifier IrcChannel)
- _connId :: Maybe ByteString
- _connChanTypes :: [Char]
- _connStatusMsg :: [Char]
- _connKnock :: !Bool
- _connNickLen :: !Int
- _connExcepts :: Maybe Char
- _connInvex :: Maybe Char
- _connUsers :: !(Map Identifier IrcUser)
- _connChanModeTypes :: !ModeTypes
- _connUserModeTypes :: !ModeTypes
- _connModes :: !Int
- _connTopicLen :: !Int
- _connMyInfo :: Maybe (ByteString, ByteString)
- _connSasl :: Maybe (ByteString, ByteString)
- _connUmode :: !ByteString
- _connSnoMask :: !ByteString
- _connPhase :: !Phase
- connNick :: Lens' IrcConnection Identifier
- connChannels :: Lens' IrcConnection (Map Identifier IrcChannel)
- connId :: Lens' IrcConnection (Maybe ByteString)
- connChanModeTypes :: Lens' IrcConnection ModeTypes
- connUserModeTypes :: Lens' IrcConnection ModeTypes
- connKnock :: Lens' IrcConnection Bool
- connNickLen :: Lens' IrcConnection Int
- connExcepts :: Lens' IrcConnection (Maybe Char)
- connInvex :: Lens' IrcConnection (Maybe Char)
- connStatusMsg :: Lens' IrcConnection [Char]
- connTopicLen :: Lens' IrcConnection Int
- connPhase :: Lens' IrcConnection Phase
- connModes :: Lens' IrcConnection Int
- connUsers :: Lens' IrcConnection (Map Identifier IrcUser)
- connMyInfo :: Lens' IrcConnection (Maybe (ByteString, ByteString))
- connSasl :: Lens' IrcConnection (Maybe (ByteString, ByteString))
- connUmode :: Lens' IrcConnection ByteString
- connSnoMask :: Lens' IrcConnection ByteString
- defaultIrcConnection :: IrcConnection
- data Phase
- data IrcChannel = IrcChannel {
- _chanTopic :: Maybe (Maybe (Text, ByteString, UTCTime))
- _chanUsers :: !(Map Identifier String)
- _chanModes :: Maybe (Map Char ByteString)
- _chanCreation :: Maybe UTCTime
- _chanMaskLists :: Map Char [IrcMaskEntry]
- _chanUrl :: Maybe ByteString
- chanTopic :: Lens' IrcChannel (Maybe (Maybe (Text, ByteString, UTCTime)))
- chanUsers :: Lens' IrcChannel (Map Identifier String)
- chanModes :: Lens' IrcChannel (Maybe (Map Char ByteString))
- chanCreation :: Lens' IrcChannel (Maybe UTCTime)
- chanMaskLists :: Lens' IrcChannel (Map Char [IrcMaskEntry])
- chanUrl :: Lens' IrcChannel (Maybe ByteString)
- data ModeTypes = ModeTypes {
- _modesLists :: String
- _modesAlwaysArg :: String
- _modesSetArg :: String
- _modesNeverArg :: String
- _modesPrefixModes :: [(Char, Char)]
- modesLists :: Lens' ModeTypes String
- modesAlwaysArg :: Lens' ModeTypes String
- modesSetArg :: Lens' ModeTypes String
- modesNeverArg :: Lens' ModeTypes String
- modesPrefixModes :: Lens' ModeTypes [(Char, Char)]
- defaultChanModeTypes :: ModeTypes
- defaultUmodeTypes :: ModeTypes
- data IrcMaskEntry = IrcMaskEntry {}
- maskEntryMask :: Lens' IrcMaskEntry ByteString
- maskEntryWho :: Lens' IrcMaskEntry ByteString
- maskEntryStamp :: Lens' IrcMaskEntry UTCTime
- data IrcUser = IrcUser {
- _usrAway :: !Bool
- _usrAccount :: !(Maybe ByteString)
- _usrHost :: !(Maybe ByteString)
- usrAway :: Lens' IrcUser Bool
- usrAccount :: Lens' IrcUser (Maybe ByteString)
- usrHost :: Lens' IrcUser (Maybe ByteString)
- defaultIrcUser :: IrcUser
- runLogic :: (Functor m, Monad m) => UTCTime -> (forall r. LogicOp r -> m r) -> Logic a -> m (Either String a)
- data LogicOp r
- = Expect (MsgFromServer -> r)
- | Emit ByteString r
- | Record Identifier IrcMessage r
- data Logic a
- advanceModel :: MsgFromServer -> IrcConnection -> Logic IrcConnection
- isChannelName :: Identifier -> IrcConnection -> Bool
- isNickName :: Identifier -> IrcConnection -> Bool
- isMyNick :: Identifier -> IrcConnection -> Bool
- splitStatusMsg :: Identifier -> IrcConnection -> (String, Identifier)
- splitModes :: ModeTypes -> ByteString -> [ByteString] -> Maybe [(Bool, Char, ByteString)]
- unsplitModes :: [(Bool, Char, ByteString)] -> [ByteString]
- nickHasModeInChannel :: Identifier -> Char -> Identifier -> IrcConnection -> Bool
- channelHasMode :: Identifier -> Char -> IrcConnection -> Bool
IRC Connection model
data IrcConnection Source
IrcConnection
is the state of an IRC connection. It maintains
channel membership, user and channel modes, and other connection
state.
IrcConnection | |
|
defaultIrcConnection :: IrcConnection Source
IrcConnection
value with everything unspecified
Phases
IRC Channel model
data IrcChannel Source
IrcChannel
represents the current state of a channel
as seen on the connection. It includes all user lists,
modes, and other metadata about a channel.
IrcChannel | |
|
chanTopic :: Lens' IrcChannel (Maybe (Maybe (Text, ByteString, UTCTime))) Source
chanModes :: Lens' IrcChannel (Maybe (Map Char ByteString)) Source
Mode Settings
Settings that describe how to interpret channel modes
ModeTypes | |
|
defaultChanModeTypes :: ModeTypes Source
The channel modes used by Freenode
defaultUmodeTypes :: ModeTypes Source
The default UMODE as defined by Freenode
Channel Mask Entry
data IrcMaskEntry Source
Mask entries are used to represent an entry in a ban list for a channel.
User metadata
IrcUser
is the type of user-level metadata tracked for
the users visible on the current IRC connection.
IrcUser | |
|
defaultIrcUser :: IrcUser Source
This represents the metadata of an unknown user.
Model execution
runLogic :: (Functor m, Monad m) => UTCTime -> (forall r. LogicOp r -> m r) -> Logic a -> m (Either String a) Source
Execute the Logic
value using a given operation for sending and
recieving IRC messages.
Expect (MsgFromServer -> r) | |
Emit ByteString r | |
Record Identifier IrcMessage r |
General functionality
advanceModel :: MsgFromServer -> IrcConnection -> Logic IrcConnection Source
Primary state machine step function. Call this function with a timestamp
and a server message to update the IrcConnection
state. If additional
messages are required they will be requested via the Logic
type.
isChannelName :: Identifier -> IrcConnection -> Bool Source
Predicate for identifiers to identify which represent channel names.
Channel prefixes are configurable, but the most common is #
isNickName :: Identifier -> IrcConnection -> Bool Source
Predicate for identifiers to identify which represent nicknames
isMyNick :: Identifier -> IrcConnection -> Bool Source
Predicate to determine if a given identifier is the primary nick for the given connection.
splitStatusMsg :: Identifier -> IrcConnection -> (String, Identifier) Source
:: ModeTypes | mode interpretation |
-> ByteString | modes |
-> [ByteString] | arguments |
-> Maybe [(Bool, Char, ByteString)] |
Split up a mode change command and arguments into individual changes given a configuration.
unsplitModes :: [(Bool, Char, ByteString)] -> [ByteString] Source
:: Identifier | nick |
-> Char | mode |
-> Identifier | channel |
-> IrcConnection | |
-> Bool |
:: Identifier | channel |
-> Char | mode |
-> IrcConnection | |
-> Bool |