irc-core-2.13: IRC core library for glirc

Copyright | (c) Eric Mertens 2016
License | ISC
Maintainer | emertens@gmail.com
Safe Haskell | None
Language | Haskell2010

Irc.Message

Contents

- High-level messages
- Properties of messages
- Helper functions

Description

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 !Text !ReplyCode [Text]
  - | Nick !Source !Identifier
  - | Join !Source !Identifier !Text !Text
  - | Part !Source !Identifier (Maybe Text)
  - | Quit !Source (Maybe Text)
  - | Kick !Source !Identifier !Identifier !Text
  - | Kill !Source !Identifier !Text
  - | Topic !Source !Identifier !Text
  - | Privmsg !Source !Identifier !Text
  - | Ctcp !Source !Identifier !Text !Text
  - | CtcpNotice !Source !Identifier !Text !Text
  - | Notice !Source !Identifier !Text
  - | Mode !Source !Identifier [Text]
  - | Authenticate !Text
  - | Cap !CapCmd
  - | Ping [Text]
  - | Pong [Text]
  - | Error !Text
  - | BatchStart !Text !Text [Text]
  - | BatchEnd !Text
  - | Account !Source !Text
  - | Chghost !Source !Text !Text
  - | Wallops !Source !Text
  - | Invite !Source !Identifier !Identifier
  - | Away !Source (Maybe Text)
  - | Tagmsg !Source !Identifier
- data CapCmd
  - = CapLs !CapMore [(Text, Maybe Text)]
  - | CapList [Text]
  - | CapAck [Text]
  - | CapNak [Text]
  - | CapNew [(Text, Maybe Text)]
  - | CapDel [Text]
- data CapMore
  - = CapMore
  - | CapDone
- cookIrcMsg :: RawIrcMsg -> IrcMsg
- data MessageTarget
  - = TargetUser !Identifier
  - | TargetWindow !Identifier
  - | TargetNetwork
- ircMsgText :: IrcMsg -> Text
- msgTarget :: Identifier -> IrcMsg -> MessageTarget
- msgActor :: IrcMsg -> Maybe Source
- msgSource :: RawIrcMsg -> Maybe Source
- isNickChar :: Char -> Bool
- nickSplit :: Text -> [Text]
- computeMaxMessageLength :: UserInfo -> Text -> Int
- capCmdText :: CapCmd -> Text
- data Source = Source {
  - srcUser :: !UserInfo
  - srcAcct :: !Text
  }

# High-level messages

data IrcMsg Source #

High-level IRC message representation

Constructors

UnknownMsg !RawIrcMsg | pass-through for unhandled messages
Reply !Text !ReplyCode [Text] | server code arguments
Nick !Source !Identifier | old new
Join !Source !Identifier !Text !Text | user channel account account gecos
Part !Source !Identifier (Maybe Text) | user channel reason
Quit !Source (Maybe Text) | user reason
Kick !Source !Identifier !Identifier !Text | kicker channel kickee comment
Kill !Source !Identifier !Text | killer killee reason
Topic !Source !Identifier !Text | user channel topic
Privmsg !Source !Identifier !Text | source target txt
Ctcp !Source !Identifier !Text !Text | source target command txt
CtcpNotice !Source !Identifier !Text !Text | source target command txt
Notice !Source !Identifier !Text | source target txt
Mode !Source !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 !Source !Text | user account name changed (account-notify extension)
Chghost !Source !Text !Text | Target, new username and new hostname
Wallops !Source !Text | Braodcast message: Source, message
Invite !Source !Identifier !Identifier | sender target channel
Away !Source (Maybe Text) |
Tagmsg !Source !Identifier | source target

#### Instances

Instances details

Show IrcMsg Source # |
Instance details Defined in Irc.Message Methods showsPrec :: Int -> IrcMsg -> ShowS Source # show :: IrcMsg -> String Source # showList :: [IrcMsg] -> ShowS Source #

data CapCmd Source #

Sub-commands of the CAP command sent by server

Constructors

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)

#### Instances

Instances details

Read CapCmd Source # |
Instance details Defined in Irc.Message Methods readsPrec :: Int -> ReadS CapCmd Source # readList :: ReadS [CapCmd] Source # readPrec :: ReadPrec CapCmd Source # readListPrec :: ReadPrec [CapCmd] Source #
Show CapCmd Source # |
Instance details Defined in Irc.Message Methods showsPrec :: Int -> CapCmd -> ShowS Source # show :: CapCmd -> String Source # showList :: [CapCmd] -> ShowS Source #
Eq CapCmd Source # |
Instance details Defined in Irc.Message Methods (==) :: CapCmd -> CapCmd -> Bool Source # (/=) :: CapCmd -> CapCmd -> Bool Source #
Ord CapCmd Source # |
Instance details Defined in Irc.Message Methods compare :: CapCmd -> CapCmd -> Ordering Source # (<) :: CapCmd -> CapCmd -> Bool Source # (<=) :: CapCmd -> CapCmd -> Bool Source # (>) :: CapCmd -> CapCmd -> Bool Source # (>=) :: CapCmd -> CapCmd -> Bool Source # max :: CapCmd -> CapCmd -> CapCmd Source # min :: CapCmd -> CapCmd -> CapCmd Source #

data CapMore Source #

Constructors

CapMore |
CapDone |

#### Instances

Instances details

Read CapMore Source # |
Instance details Defined in Irc.Message Methods readsPrec :: Int -> ReadS CapMore Source # readList :: ReadS [CapMore] Source # readPrec :: ReadPrec CapMore Source # readListPrec :: ReadPrec [CapMore] Source #
Show CapMore Source # |
Instance details Defined in Irc.Message Methods showsPrec :: Int -> CapMore -> ShowS Source # show :: CapMore -> String Source # showList :: [CapMore] -> ShowS Source #
Eq CapMore Source # |
Instance details Defined in Irc.Message Methods (==) :: CapMore -> CapMore -> Bool Source # (/=) :: CapMore -> CapMore -> Bool Source #
Ord CapMore Source # |
Instance details Defined in Irc.Message Methods compare :: CapMore -> CapMore -> Ordering Source # (<) :: CapMore -> CapMore -> Bool Source # (<=) :: CapMore -> CapMore -> Bool Source # (>) :: CapMore -> CapMore -> Bool Source # (>=) :: CapMore -> CapMore -> Bool Source # max :: CapMore -> CapMore -> CapMore Source # min :: CapMore -> CapMore -> CapMore Source #

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

Constructors

TargetUser !Identifier | Metadata update for a user
TargetWindow !Identifier | Directed message to channel or from user
TargetNetwork | Network-level message

#### Instances

Instances details

Show MessageTarget Source # |
Instance details Defined in Irc.Message Methods showsPrec :: Int -> MessageTarget -> ShowS Source # show :: MessageTarget -> String Source # showList :: [MessageTarget] -> ShowS Source #

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.

msgActor :: IrcMsg -> Maybe Source Source #

`UserInfo` of the user responsible for a message.

msgSource :: RawIrcMsg -> Maybe Source Source #

# Helper functions

isNickChar :: Char -> Bool Source #

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 #

data Source Source #

Constructors

Source |

Fields

- srcUser :: !UserInfo
- srcAcct :: !Text

#### Instances

Instances details

Show Source Source # |
Instance details Defined in Irc.Message Methods showsPrec :: Int -> Source -> ShowS Source # show :: Source -> String Source # showList :: [Source] -> ShowS Source #