module Network.SimpleIRC.Types
(
IrcConfig(..)
, IrcServer(..)
, SIrcCommand(..)
, IrcEvent(..)
, EventFunc
, IrcMessage(..)
) where
import qualified Data.ByteString.Char8 as B
import Control.Concurrent (ThreadId)
import Control.Concurrent.Chan (Chan)
import System.IO (Handle)
import Data.Unique (Unique)
import Data.Map (Map)
import Data.Typeable
data IrcConfig = IrcConfig
{ cAddr :: String
, cPort :: Int
, cNick :: String
, cUsername :: String
, cRealname :: String
, cChannels :: [String]
, cEvents :: [IrcEvent]
, cCTCPVersion :: String
, cCTCPTime :: IO String
}
data SIrcCommand =
SIrcAddEvent (Unique, IrcEvent)
| SIrcChangeEvents (Map Unique IrcEvent)
| SIrcRemoveEvent Unique
data IrcServer = IrcServer
{ sAddr :: B.ByteString
, sPort :: Int
, sNickname :: B.ByteString
, sUsername :: B.ByteString
, sRealname :: B.ByteString
, sChannels :: [B.ByteString]
, sEvents :: Map Unique IrcEvent
, sSock :: Maybe Handle
, sListenThread :: Maybe ThreadId
, sCmdChan :: Chan SIrcCommand
, sDebug :: Bool
, sCTCPVersion :: String
, sCTCPTime :: IO String
}
type EventFunc = (IrcServer -> IrcMessage -> IO ())
data IrcEvent =
Privmsg EventFunc
| Numeric EventFunc
| Ping EventFunc
| Join EventFunc
| Part EventFunc
| Mode EventFunc
| Topic EventFunc
| Invite EventFunc
| Kick EventFunc
| Quit EventFunc
| Nick EventFunc
| Notice EventFunc
| RawMsg EventFunc
| Disconnect (IrcServer -> IO ())
instance Show IrcEvent where
show (Privmsg _) = "IrcEvent - Privmsg"
show (Numeric _) = "IrcEvent - Numeric"
show (Ping _) = "IrcEvent - Ping"
show (Join _) = "IrcEvent - Join"
show (Part _) = "IrcEvent - Part"
show (Mode _) = "IrcEvent - Mode"
show (Topic _) = "IrcEvent - Topic"
show (Invite _) = "IrcEvent - Invite"
show (Kick _) = "IrcEvent - Kick"
show (Quit _) = "IrcEvent - Quit"
show (Nick _) = "IrcEvent - Nick"
show (Notice _) = "IrcEvent - Notice"
show (RawMsg _) = "IrcEvent - RawMsg"
show (Disconnect _) = "IrcEvent - Disconnect"
data IrcMessage = IrcMessage
{ mNick :: Maybe B.ByteString
, mHost :: Maybe B.ByteString
, mServer :: Maybe B.ByteString
, mCode :: B.ByteString
, mMsg :: B.ByteString
, mChan :: Maybe B.ByteString
, mOther :: Maybe [B.ByteString]
, mRaw :: B.ByteString
} deriving (Show, Typeable)