summaryrefslogtreecommitdiffstats
path: root/Hirc/Types.hs
blob: c516ba77e89f548adee975b90a5e50d5eb7210df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{-# LANGUAGE RecordWildCards #-}

module Hirc.Types where

import System.IO (Handle)
import Control.Concurrent.STM (TVar)
import Control.Monad.Reader (ReaderT)

type Command = String
type Param = String
type Receiver = String

data Message =
  Message {
    m_prefix :: Maybe Prefix,
    m_command :: Command,
    m_params :: [Param]
  }
  deriving Show

data Error =
    BadMessage String
  deriving Show

data Prefix =
  Prefix {
    p_name :: String,
    p_user :: Maybe String,
    p_host :: Maybe String
  }
  deriving Show

type Net = ReaderT Bot IO

data Bot = Bot {
  bot_server :: Server,
  bot_nick :: TVar String,
  bot_chan :: TVar String,
  bot_socket :: Handle
}

data Config =
    Config {
      config_server :: Server,
      config_nick :: String,
      config_chan :: String
    }
  deriving Show

data Hooks =
    Hooks {
      hooks_onConnect :: Net (),
      hooks_onDisconnect :: Net (),
      hooks_onError :: Error -> Net (),
      hooks_onMessage :: Message -> Net ()
      --hooks_shell :: Net()
    }

data Server =
    Server {
      hostname :: String,
      port :: Int
    }
instance Show Server where
    show Server{..} = hostname ++ ":" ++ show port