Copyright | (c) Eric Mertens 2016 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
This module defines high-level IRC commands. Commands are interpreted and their arguments are extracted into the appropriate types.
Synopsis
- data IrcMsg
- = UnknownMsg !RawIrcMsg
- | Reply !ReplyCode [Text]
- | Nick !UserInfo !Identifier
- | Join !UserInfo !Identifier !Text
- | Part !UserInfo !Identifier (Maybe Text)
- | Quit !UserInfo (Maybe Text)
- | Kick !UserInfo !Identifier !Identifier !Text
- | Topic !UserInfo !Identifier !Text
- | Privmsg !UserInfo !Identifier !Text
- | Ctcp !UserInfo !Identifier !Text !Text
- | CtcpNotice !UserInfo !Identifier !Text !Text
- | Notice !UserInfo !Identifier !Text
- | Mode !UserInfo !Identifier [Text]
- | Authenticate !Text
- | Cap !CapCmd
- | Ping [Text]
- | Pong [Text]
- | Error !Text
- | BatchStart !Text !Text [Text]
- | BatchEnd !Text
- | Account !UserInfo !Text
- | Chghost !UserInfo !Text !Text
- | Wallops !UserInfo !Text
- data CapCmd
- data CapMore
- cookIrcMsg :: RawIrcMsg -> IrcMsg
- data MessageTarget
- ircMsgText :: IrcMsg -> Text
- msgTarget :: Identifier -> IrcMsg -> MessageTarget
- msgActor :: IrcMsg -> Maybe UserInfo
- nickSplit :: Text -> [Text]
- computeMaxMessageLength :: UserInfo -> Text -> Int
- capCmdText :: CapCmd -> Text
High-level messages
High-level IRC message representation
UnknownMsg !RawIrcMsg | pass-through for unhandled messages |
Reply !ReplyCode [Text] | code arguments |
Nick !UserInfo !Identifier | old new |
Join !UserInfo !Identifier !Text | user channel account(extended-join) |
Part !UserInfo !Identifier (Maybe Text) | user channel reason |
Quit !UserInfo (Maybe Text) | user reason |
Kick !UserInfo !Identifier !Identifier !Text | kicker channel kickee comment |
Topic !UserInfo !Identifier !Text | user channel topic |
Privmsg !UserInfo !Identifier !Text | source target txt |
Ctcp !UserInfo !Identifier !Text !Text | source target command txt |
CtcpNotice !UserInfo !Identifier !Text !Text | source target command txt |
Notice !UserInfo !Identifier !Text | source target txt |
Mode !UserInfo !Identifier [Text] | source target txt |
Authenticate !Text | parameters |
Cap !CapCmd | cap command and parameters |
Ping [Text] | parameters |
Pong [Text] | parameters |
Error !Text | message |
BatchStart !Text !Text [Text] | reference-id type parameters |
BatchEnd !Text | reference-id |
Account !UserInfo !Text | user account name changed (account-notify extension) |
Chghost !UserInfo !Text !Text | Target, new username and new hostname |
Wallops !UserInfo !Text | Braodcast message: Source, message |
Sub-commands of the CAP command sent by server
CapLs !CapMore [(Text, Maybe Text)] | list of supported caps |
CapList [Text] | list of active caps |
CapAck [Text] | request accepted |
CapNak [Text] | request denied |
CapNew [(Text, Maybe Text)] | new capability available (cap-notify extension) |
CapDel [Text] | capability removed (cap-notify extension) |
cookIrcMsg :: RawIrcMsg -> IrcMsg Source #
Interpret a low-level RawIrcMsg
as a high-level IrcMsg
.
Messages that can't be understood are wrapped in UnknownMsg
.
Properties of messages
data MessageTarget Source #
Targets used to direct a message to a window for display
TargetUser !Identifier | Metadata update for a user |
TargetWindow !Identifier | Directed message to channel or from user |
TargetNetwork | Network-level message |
TargetHidden | Completely hidden message |
Instances
Show MessageTarget Source # | |
Defined in Irc.Message showsPrec :: Int -> MessageTarget -> ShowS # show :: MessageTarget -> String # showList :: [MessageTarget] -> ShowS # |
ircMsgText :: IrcMsg -> Text Source #
Text representation of an IRC message to be used for matching with regular expressions.
msgTarget :: Identifier -> IrcMsg -> MessageTarget Source #
Target information for the window that could be appropriate to display this message in.
Helper functions
nickSplit :: Text -> [Text] Source #
Split a nick into text parts group by whether or not those parts are valid nickname characters.
computeMaxMessageLength :: UserInfo -> Text -> Int Source #
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
capCmdText :: CapCmd -> Text Source #