Archived
1
0
Fork 0
This repository has been archived on 2025-03-10. You can view files and clone it, but cannot push or open issues or pull requests.
hsbot/Hsbot/Main.hs
2009-08-07 00:19:14 +02:00

38 lines
948 B
Haskell

module Hsbot.Main
( imain
) where
import Control.Concurrent
import Control.Concurrent.Chan
import Control.Monad
import System.IO
import System.Plugins
import qualified Config as C
import Hsbot.Core
import Hsbot.IRC
type Reboot = (Module -> Bot -> IO ())
-- | Bot's first main entry point
imain :: Module -> Reboot -> IO ()
imain modul' reboot = imain' modul' reboot newbot
-- | Bot's main entry point
imain' :: Module -> Reboot -> Bot -> IO ()
imain' modul' reboot bot = do
putStrLn "yeah"
putStrLn "Connecting servers..."
servers' <- mapM connectServer (ircServers C.config)
putStrLn "Joining channels..."
mapM_ initServer servers'
return ()
-- | Thread entry point for socket listeners
listener :: (Chan IrcOutput) -> (IrcServer, Handle) -> IO ()
listener chan (server, handle) = forever $ do
str <- hGetLine handle
writeChan chan (Str str)
if ping str then pong handle str
else return ()