diff options
author | tv <tv@shackspace.de> | 2015-10-09 00:05:29 +0200 |
---|---|---|
committer | tv <tv@shackspace.de> | 2015-10-09 00:05:29 +0200 |
commit | cd27619974479911463ec2eef8abc5c6b86fedb0 (patch) | |
tree | c6b0b521a24286420d182802078887c6a68d6ecb | |
parent | 7627809a1627a0292cfa75da77f129eee0fa0a2b (diff) |
listen: Don't query config continuously
-rw-r--r-- | hirc.hs | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -63,18 +63,18 @@ run = do Config{..} <- asks config write "NICK" nick write "USER" (nick++" 0 * :hirc bot") - asks socket >>= listen + ask >>= listen -- Process each line from the server -listen :: Handle -> Net () -listen h = forever $ do - c@Config{..} <- asks config - let filename = server <> (':' : show port) +listen :: Bot -> Net () +listen Bot{config=c@Config{..},socket=h} = forever $ do s <- init `fmap` io (hGetLine h) io (putStrLn s) case parse P.message filename s of Right m -> eval m x -> io $ putStrLn $ show x + where + filename = server <> (':' : show port) -- Dispatch a command eval :: Message -> Net () |