From 17c092a07ad03bbb77bcf629463f78b5a49dc4cb Mon Sep 17 00:00:00 2001 From: pb Date: Sun, 14 Mar 2010 14:24:49 +0000 Subject: git-svn-id: https://ssl.buetow.org/repos/hsbot/trunk@27 9f8f72e9-4bf4-416e-b76e-7d4203597157 --- IRC.hs | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/IRC.hs b/IRC.hs index 02f0a59..d1e4724 100644 --- a/IRC.hs +++ b/IRC.hs @@ -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 -- cgit v1.2.3