erisbot :: BotConf -> IO ()
erisbot conf@BotConf {..} = withSocketsDo $ do
  sock <- connectTo network (PortNumber port)
  putStrLn $ "Connecting to " ++ network ++ ":" ++ show port ++ "..."
  hSetBuffering sock LineBuffering
  botState <- newBotState conf ()
  runBot botState $ do
    debugMode .= True
    debugMsg "initializing socket reader"
    forkBot_ (socketReader sock)
    debugMsg "initializing socket writer"
    forkBot_ (socketWriter sock)
    debugMsg "initializing command dispatcher"
    forkInputListener_ commandDispatcher
    forkInputListener_ pingListener
    forkInputListener_ urlListener
    forkInputListener_ rejoinListener
    forkBot_ annoyingNickChanger
    forkInputListenerWithState_ HM.empty sedListener
    addCommand defaultCommand { name =  "say"
                              , handler = sayCommand
                              }
    threadDelay 2000000
    sendMsg "NICK" [BS.pack nick] ""
    sendMsg "USER" [BS.pack user, "0", "0"] (BS.pack realname)
    waitFor001 $ do
      forM_ plugins (uncurry loadPlugin)
      forM_ channels $ \c ->
        sendMsg "JOIN" [BS.pack c] ""
    debugMsg "main sleeping"
    sleepForever
  
  where sleepForever = threadDelay maxBound >> sleepForever
erisbot :: BotConf -> IO ()
erisbot conf@BotConf {..} = withSocketsDo $ do
  sock <- connectTo network (PortNumber port)
  putStrLn $ "Connecting to " ++ network ++ ":" ++ show port ++ "..."
  hSetBuffering sock LineBuffering
  botState <- newBotState conf ()
  runBot botState $ do
    debugMode .= True
    debugMsg "initializing socket reader"
    forkBot_ (socketReader sock)
    debugMsg "initializing socket writer"
    forkBot_ (socketWriter sock)
    debugMsg "initializing command dispatcher"
    forkInputListener_ commandDispatcher
    forkInputListener_ pingListener
    forkInputListener_ urlListener
    forkInputListener_ rejoinListener
    forkBot_ annoyingNickChanger
    forkInputListenerWithState_ HM.empty sedListener
    addCommand defaultCommand { name =  "say"
                              , handler = sayCommand
                              }
    threadDelay 2000000
    sendMsg "NICK" [BS.pack nick] ""
    sendMsg "USER" [BS.pack user, "0", "0"] (BS.pack realname)
    waitFor001 $ do
      forM_ plugins (uncurry loadPlugin)
      forM_ channels $ \c ->
        sendMsg "JOIN" [BS.pack c] ""
    debugMsg "main sleeping"
    sleepForever
  
  where sleepForever = threadDelay maxBound >> sleepForever
erisbot conf@BotConf {..} = withSocketsDo $ do
  sock <- connectTo network (PortNumber port)
  putStrLn $ "Connecting to " ++ network ++ ":" ++ show port ++ "..."
  hSetBuffering sock LineBuffering
  botState <- newBotState conf ()
  runBot botState $ do
    debugMode .= True
    debugMsg "initializing socket reader"
    forkBot_ (socketReader sock)
    debugMsg "initializing socket writer"
    forkBot_ (socketWriter sock)
    debugMsg "initializing command dispatcher"
    forkInputListener_ commandDispatcher
    forkInputListener_ pingListener
    forkInputListener_ urlListener
    forkInputListener_ rejoinListener
    forkBot_ annoyingNickChanger
    forkInputListenerWithState_ HM.empty sedListener
    addCommand defaultCommand { name =  "say"
                              , handler = sayCommand
                              }
    threadDelay 2000000
    sendMsg "NICK" [BS.pack nick] ""
    sendMsg "USER" [BS.pack user, "0", "0"] (BS.pack realname)
    waitFor001 $ do
      forM_ plugins (uncurry loadPlugin)
      forM_ channels $ \c ->
        sendMsg "JOIN" [BS.pack c] ""
    debugMsg "main sleeping"
    sleepForever
  
  where sleepForever = threadDelay maxBound >> sleepForever