{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE OverloadedStrings #-}
module Irc.Message
(
IrcMessage(..)
, IrcMessageType(..)
, mesgType
, mesgSender
, mesgStamp
, mesgStatus
, mesgMe
, mesgModes
, defaultIrcMessage
, _PrivMsgType
, _NoticeMsgType
, _ActionMsgType
, _AwayMsgType
, _JoinMsgType
, _KickMsgType
, _PartMsgType
, _QuitMsgType
, _NickMsgType
, _TopicMsgType
, _ErrorMsgType
, _ErrMsgType
, _ModeMsgType
, _InviteMsgType
, _KnockMsgType
, _CallerIdMsgType
, _CallerIdDeliveredMsgType
, _CtcpReqMsgType
, _CtcpRspMsgType
) where
import Control.Lens
import Data.ByteString (ByteString)
import Data.Text (Text)
import Data.Time
import Data.Time.Clock.POSIX
import Irc.Core
import Irc.Format
data IrcMessage = IrcMessage
{ _mesgType :: !IrcMessageType
, _mesgSender :: !UserInfo
, _mesgStamp :: !UTCTime
, _mesgMe :: !Bool
, _mesgModes :: String
, _mesgStatus :: String
}
deriving (Read, Show)
defaultIrcMessage :: IrcMessage
defaultIrcMessage = IrcMessage
{ _mesgType = PrivMsgType ""
, _mesgSender = UserInfo "" Nothing Nothing
, _mesgStamp = posixSecondsToUTCTime 0
, _mesgMe = False
, _mesgModes = ""
, _mesgStatus = ""
}
data IrcMessageType
= PrivMsgType Text
| NoticeMsgType Text
| ActionMsgType Text
| AwayMsgType Text
| JoinMsgType
| KickMsgType Identifier Text
| PartMsgType Text
| QuitMsgType Text
| NickMsgType Identifier
| TopicMsgType Text
| ErrorMsgType Text
| ErrMsgType IrcError
| ModeMsgType Bool Char ByteString
| InviteMsgType
| KnockMsgType
| CallerIdMsgType
| CallerIdDeliveredMsgType
| CtcpReqMsgType ByteString ByteString
| CtcpRspMsgType ByteString ByteString
deriving (Read, Show)
makeLenses ''IrcMessage
makePrisms ''IrcMessageType