{-# LANGUAGE MultiParamTypeClasses #-} module IrcBot.IrcBot where import Network.Socket import IrcBot.BotNetworkCommands import IrcBot.BotActions import IrcBot.BotNetwork import Network.Connection import qualified Control.Concurrent as T import qualified Data.ByteString.Char8 as C import IrcBot.Definitions.ServerAddress connectToIRCServer :: IServerAddress -> IO () connectToIRCServer serverAddress = do newSock <- connectToServer (server serverAddress) (fromIntegral (port serverAddress)) (ssl serverAddress) print "[connected to server]" initBotName newSock (nickname serverAddress) initBotNick newSock (nickname serverAddress) initAuthNickServ newSock (nickname serverAddress) (password serverAddress) print "waiting for identification with very stupid way" T.threadDelay (1000000 * 15) --wait wait let channelsToJoin = channels serverAddress mapM (\x -> joinChannel newSock x) channelsToJoin connectionLoop newSock serverAddress print "sleeping 15 sec for reconnect" -- 1000000 is 1 second T.threadDelay (1000000 * 15) print "reconnecting sequence initializing" -- this is a recursive function and its maintaining own connectivity -- how deep can i call this function? or just compiler optimizes for me? no idea connectToIRCServer (serverAddress)