summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2015-10-09 00:05:29 +0200
committertv <tv@shackspace.de>2015-10-09 00:05:29 +0200
commitcd27619974479911463ec2eef8abc5c6b86fedb0 (patch)
treec6b0b521a24286420d182802078887c6a68d6ecb
parent7627809a1627a0292cfa75da77f129eee0fa0a2b (diff)
listen: Don't query config continuously
-rw-r--r--hirc.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/hirc.hs b/hirc.hs
index b6ce8cf..6a629fd 100644
--- a/hirc.hs
+++ b/hirc.hs
@@ -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 ()