diff options
| -rw-r--r-- | IRC.hs | 32 |
1 files changed, 20 insertions, 12 deletions
@@ -27,21 +27,29 @@ ircWrite h s t = do ircPrivmsg :: Handle -> IrcMessage -> Env -> String -> IO () ircPrivmsg h msg (Env state conf) s = do - if isMultiline s then ircPrivmsg' (lines s) else ircPrivmsg' [s] + if isMultiline s + then ircPrivmsg' (lines s) + else ircPrivmsg' [s] where ircPrivmsg' [] = return () ircPrivmsg' (x:xs) = - let maxMessageSize = getUnwrappedInt "maxMessageSize" conf - receiver = if (isQuery msg) then from msg else currentChannel state + let maxMessageSize = + getUnwrappedInt "maxMessageSize" conf + receiver = + if (isQuery msg) + then from msg + else currentChannel state in if length x > maxMessageSize - then do ircWrite h "PRIVMSG" (receiver ++ " :" - ++ (take maxMessageSize x) ++ "...") - ircWrite h "PRIVMSG" (receiver ++ " :" - ++ "...this message has been cut to " - ++ (show maxMessageSize) ++ " chars") - ircPrivmsg' xs - else do ircWrite h "PRIVMSG" (receiver ++ " :" ++ x) - ircPrivmsg' xs + then do + ircWrite h "PRIVMSG" (receiver ++ " :" + ++ (take maxMessageSize x) ++ "...") + ircWrite h "PRIVMSG" (receiver ++ " :" + ++ "...this message has been cut to " + ++ (show maxMessageSize) ++ " chars") + ircPrivmsg' xs + else do + ircWrite h "PRIVMSG" (receiver ++ " :" ++ x) + ircPrivmsg' xs ircConnect :: Env -> IO () ircConnect (Env state conf) = do @@ -54,7 +62,7 @@ ircConnect (Env state conf) = do hSetBuffering h NoBuffering ircWrite h "NICK" ircNick ircWrite h "USER" $ ircNick ++ " 0 * :" ++ ircUser - ircEvalLoop h (Env (state { currentChannel = ircChannel }) conf) + ircEvalLoop h (Env state { currentChannel = ircChannel } conf) ircEvalLoop :: Handle -> Env -> IO () ircEvalLoop h env = forever $ do |
