From c07b9562e72133ccf5a64e880beb53cb8499a642 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 8 Oct 2015 20:39:37 +0200 Subject: Parse IRC messages --- hirc.hs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'hirc.hs') diff --git a/hirc.hs b/hirc.hs index 86bd135..82b6cd2 100644 --- a/hirc.hs +++ b/hirc.hs @@ -1,10 +1,14 @@ import Data.List +import Data.Monoid import Network import System.IO import System.Exit import Control.Arrow import Control.Monad.Reader import Control.Exception +import Hirc.Parser as P +import Hirc.Types +import Text.Parsec (parse) import Text.Printf server = "irc.freenode.org" @@ -49,12 +53,14 @@ listen :: Handle -> Net () listen h = forever $ do s <- init `fmap` io (hGetLine h) io (putStrLn s) + io (putStrLn $ show $ parse P.message filename s) if ping s then pong s else eval (clean s) where forever a = a >> forever a clean = drop 1 . dropWhile (/= ':') . drop 1 ping x = "PING :" `isPrefixOf` x pong x = write "PONG" (':' : drop 6 x) + filename = server <> (':' : show port) -- Dispatch a command eval :: String -> Net () -- cgit v1.2.3