42 lines
997 B
Haskell
42 lines
997 B
Haskell
|
{-# LANGUAGE MultiWayIf #-}
|
||
|
|
||
|
|
||
|
import IrcBot.IrcBot as I
|
||
|
import IrcBot.JsonConfigDecoder
|
||
|
import qualified Data.ByteString.Lazy as C
|
||
|
import Data.Aeson
|
||
|
import Data.Maybe
|
||
|
import qualified Control.Concurrent as T
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
initWithOptions:: Maybe IOptions -> IO()
|
||
|
initWithOptions (Just options) = do
|
||
|
let serverAddresses = (servers options)
|
||
|
mapM (\x -> T.forkIO (I.connectToIRCServer x)) serverAddresses
|
||
|
print "[all threads initialized!]"
|
||
|
|
||
|
initWithOptions _ = print "BAD OPTIONS JSON"
|
||
|
|
||
|
|
||
|
mainLoop :: IO ()
|
||
|
mainLoop = do
|
||
|
T.threadDelay 1000000
|
||
|
mainLoop
|
||
|
|
||
|
main :: IO ()
|
||
|
main = do
|
||
|
|
||
|
let externalVar = []
|
||
|
output <- C.readFile ".connection.json"
|
||
|
let options = decode output :: Maybe IOptions
|
||
|
-- let servers = decode output :: Maybe IServerAddress
|
||
|
initWithOptions options
|
||
|
-- let serverAddress = fromJust serverAddressDecoded
|
||
|
|
||
|
-- mapM (\x -> I.connectToIRCServer x) servers
|
||
|
-- I.connectToIRCServer servers
|
||
|
mainLoop
|
||
|
print "its over"
|