-
Notifications
You must be signed in to change notification settings - Fork 0
/
HircBot.hs
executable file
·32 lines (26 loc) · 985 Bytes
/
HircBot.hs
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
#!/usr/bin/runhaskell
-- HIRC v0.1
-- Nate Book
module HircBot where
-- Haskell modules
import System.Environment
-- HIrcBot modules
import HircIO -- logging, config, network
import HircState -- HircState object and all types
import HircEvents -- What to do on abstracted IRC events
main =
do
ircNetInit
args <- getArgs
let argMap = parseCliArgs args
in do
state <- loadConfig
logLine state LogInfo "Welcome to HircBot. Configuration file loaded."
state <- handleCliArgs argMap state
state <- ircConnect state
logLine state LogInfo $ "Connected to " ++ (cfgHost . stateCfg $ state) ++ "."
state <- handleEvent state OnConnect
ircRecvLoop state handleMessage
where
handleMessage :: HircState -> Message -> IO HircState
handleMessage state m = handleEvent state $ OnRecv m