Safe Haskell | None |
---|---|
Language | Haskell2010 |
A small DSL for creating mode strings. The documentation contains parts from https://modern.ircdocs.horse only for quick reference. Please refer to the source for up to date documentation on individual modes!
Synopsis
- data ModeStr
- emitModeStr :: ModeStr -> ByteString
- fetchModeStr :: ServerModes -> ByteString -> Maybe ModeStr
- data ModeType
- data Mode :: ModeType -> * -> * where
- data OpaqueMode (t :: ModeType) = ModeParameter a => OpaqueMode (Mode t a)
- class ModeParameter a where
- renderMode :: a -> ByteString
- seizeMode :: Parser a
- data ModeOp where
- modeOps :: ModeStr -> NonEmpty ModeOp
- get :: Mode TypeA a -> ModeStr
- set :: SetMode m => m -> ModeSetter m
- unset :: UnsetMode m => m -> ModeUnsetter m
- ban :: Mode TypeA HostMask
- exception :: Mode TypeA HostMask
- clientLimit :: Mode TypeC Int
- inviteOnly :: Mode TypeD Void
- inviteOnlyException :: Mode TypeA HostMask
- key :: Mode TypeB Text
- secret :: Mode TypeD Void
- moderated :: Mode TypeD Void
- protectedTopic :: Mode TypeD Void
- noExternal :: Mode TypeD Void
- type UserMode = Mode TypeD Void
- pattern UserMode :: Char -> UserMode
- invisible :: UserMode
- oper :: UserMode
- localOper :: UserMode
- registered :: UserMode
- wallops :: UserMode
- type PrefixMode = Mode TypeB HostMask
- pattern PrefixMode :: Char -> PrefixMode
- founder :: PrefixMode
- protected :: PrefixMode
- operator :: PrefixMode
- halfop :: PrefixMode
- voice :: PrefixMode
- data ServerModes = ServerModes {
- typeAModes :: [OpaqueMode TypeA]
- typeBModes :: [OpaqueMode TypeB]
- typeCModes :: [OpaqueMode TypeC]
- typeDModes :: [OpaqueMode TypeD]
- defaultModes :: ServerModes
- defaultPrefixModes :: ServerModes
- defaultUserModes :: ServerModes
- type HostMask = Text
Documentation
emitModeStr :: ModeStr -> ByteString Source #
Emit a ModeStr
to a ByteString
for use in a message.
fetchModeStr :: ServerModes -> ByteString -> Maybe ModeStr Source #
Fetch a ModeStr
from a ByteString
, given some defined collection of
modes in the form of a ServerModes
. Will return Nothing
if the parsing
fails.
Instances
Eq ModeType Source # | |
Ord ModeType Source # | |
Defined in Network.Yak.Modes | |
Read ModeType Source # | |
Show ModeType Source # | |
Generic ModeType Source # | |
type Rep ModeType Source # | |
Defined in Network.Yak.Modes type Rep ModeType = D1 (MetaData "ModeType" "Network.Yak.Modes" "yak-0.2.0.0-DpGRvARnWRP1pvWDPQg9Pa" False) ((C1 (MetaCons "TypeA" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "TypeB" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "TypeC" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "TypeD" PrefixI False) (U1 :: Type -> Type))) |
data Mode :: ModeType -> * -> * where Source #
A mode is defined through a character and its type.
TypeA
: Modes that add or remove an address to or from a list. These modes MUST always have a parameter when sent from the server to a client. A client MAY issue this type of mode without an argument to obtain the current contents of the list. The numerics used to retrieve contents of Type A modes depends on the specific mode. Also see the EXTBAN parameter.TypeB
: Modes that change a setting on a channel. These modes MUST always have a parameter.TypeC
: Modes that change a setting on a channel. These modes MUST have a parameter when being set, and MUST NOT have a parameter when being unset.TypeD
: Modes that change a setting on a channel. These modes MUST NOT have a parameter.
The final type parameter to Mode
determines the parameter type of the
defined mode.
data OpaqueMode (t :: ModeType) Source #
An existential wrapper around modes that hides the parameter type, such
that modes of a similar type can be grouped together in a simple container,
such as those in a ServerModes
.
ModeParameter a => OpaqueMode (Mode t a) |
class ModeParameter a where Source #
Mode Parameters are types that can be used as parameters to some mode.
renderMode :: a -> ByteString Source #
Instances
ModeParameter Int Source # | |
Defined in Network.Yak.Modes renderMode :: Int -> ByteString Source # | |
ModeParameter Word Source # | |
Defined in Network.Yak.Modes renderMode :: Word -> ByteString Source # | |
ModeParameter Text Source # | |
Defined in Network.Yak.Modes renderMode :: Text -> ByteString Source # | |
ModeParameter Void Source # | |
Defined in Network.Yak.Modes renderMode :: Void -> ByteString Source # |
Operations that can be performed with a mode.
Building Mode Strings
Mode Strings can be built using the following three combinators. The types are polymorphic over different mode types and therefore do not fully reflect their use.
As an example consider
foo :: ModeStr foo = set ban "foo!bar@quux" <> unset moderated
which translates to
+b+m foo!bar@quux
Common Channel Modes
ban :: Mode TypeA HostMask Source #
This channel mode controls a list of client masks that are ‘banned’ from joining or speaking in the channel. If this mode has values, each of these values should be a client mask.
exception :: Mode TypeA HostMask Source #
This channel mode controls a list of client masks that are exempt from the ‘ban’ channel mode. If this mode has values, each of these values should be a client mask.
clientLimit :: Mode TypeC Int Source #
This channel mode controls whether new users may join based on the number of users who already exist in the channel. If this mode is set, its value is an integer and defines the limit of how many clients may be joined to the channel.
inviteOnly :: Mode TypeD Void Source #
This channel mode controls whether new users need to be invited to the channel before being able to join.
inviteOnlyException :: Mode TypeA HostMask Source #
This channel mode controls a list of channel masks that are exempt from the invite-only channel mode. If this mode has values, each of these values should be a client mask.
key :: Mode TypeB Text Source #
This mode letter sets a ‘key’ that must be supplied in order to join this channel. If this mode is set, its’ value is the key that is required.
secret :: Mode TypeD Void Source #
This channel mode controls whether the channel is ‘secret’, and does not have any value.
moderated :: Mode TypeD Void Source #
This channel mode controls whether users may freely talk on the channel, and does not have any value.
protectedTopic :: Mode TypeD Void Source #
This channel mode controls whether channel privileges are required to set the topic, and does not have any value.
noExternal :: Mode TypeD Void Source #
This channel mode controls whether users who are not joined to the channel can send messages to it, and does not have any value.
Common User Modes
invisible :: UserMode Source #
If a user is set to ‘invisible’, they will not show up in commands such as WHO unless they share a channel with the user that submitted the command. In addition, the only channels that will show up in a WHOIS of an invisible user will be those they share with the user that submitted the command.
localOper :: UserMode Source #
If a user has this mode, this indicates that they are a server operator. A local operator has operator privileges for their server, and not for the rest of the network.
registered :: UserMode Source #
If a user has this mode, this indicates that they have logged into a user account.
If a user has this mode, this indicates that they will receive WALLOPS messages from the server.
Channel Member Prefix Modes
pattern PrefixMode :: Char -> PrefixMode Source #
founder :: PrefixMode Source #
halfop :: PrefixMode Source #
voice :: PrefixMode Source #
Server Modes
data ServerModes Source #
ServerModes
lets you define a dictionary of modes to be passed to the
parser (see fetchModeStr
). Modes are very server specific and it is not
possible to achieve good coverage/compatibility here, so this needs to be
done in user code. See defaultModes
for a starting point. Note that
ServerModes
is a monoid, so you can easily augment the standardized modes
with custom server specific ones.
ServerModes | |
|
Instances
Semigroup ServerModes Source # | |
Defined in Network.Yak.Modes (<>) :: ServerModes -> ServerModes -> ServerModes # sconcat :: NonEmpty ServerModes -> ServerModes # stimes :: Integral b => b -> ServerModes -> ServerModes # | |
Monoid ServerModes Source # | |
Defined in Network.Yak.Modes mempty :: ServerModes # mappend :: ServerModes -> ServerModes -> ServerModes # mconcat :: [ServerModes] -> ServerModes # |