From: dopefishh Date: Thu, 13 Jul 2017 10:23:54 +0000 (+0200) Subject: Merge pull request #8 from clean-cloogle/delays X-Git-Url: https://git.martlubbers.net/?p=cloogle-irc.git;a=commitdiff_plain;h=9794a1793a22bc4cc37ed9e4c69b6907dbf64762;hp=e61557d61120ab6af49cc4f2d7b413eaf7474132 Merge pull request #8 from clean-cloogle/delays Slight improvement to #6: delay after sending message --- diff --git a/cloogle.icl b/cloogle.icl index 35b71c2..c4c93d9 100644 --- a/cloogle.icl +++ b/cloogle.icl @@ -111,18 +111,22 @@ Start w = bot ("irc.freenode.net", 6667) startup shutdown () process w process :: IRCMessage () *World -> (Maybe [IRCMessage], (), *World) process im s w = case im.irc_command of Left numr = (Just [], (), w) - Right cmd = case process` cmd w of + Right cmd = case process` im.irc_prefix cmd w of (Nothing, w) = (Nothing, (), w) (Just cs, w) = (Just $ map toPrefix cs, (), w) - process` :: IRCCommand *World -> (Maybe [IRCCommand], *World) - process` (PRIVMSG t m) w + process` :: (Maybe (Either IRCUser String)) IRCCommand *World -> (Maybe [IRCCommand], *World) + process` (Just (Left user)) (PRIVMSG t m) w | m.[0] == '!' # (msgs, w) = realProcess (split " " $ m % (1, size m)) w - = (Just $ map (PRIVMSG t) msgs, w) + = (Just $ map (PRIVMSG recipient) msgs, w) = (Just [], w) - process` (PING t mt) w = (Just [PONG t mt], w) - process` _ w = (Just [], w) + where + recipient = case (\(CSepList [t:_]) -> t.[0]) t of + '#' -> t + _ -> CSepList [user.irc_nick] + process` _ (PING t mt) w = (Just [PONG t mt], w) + process` _ _ w = (Just [], w) realProcess :: [String] *World -> ([String], *World) realProcess ["help",x:xs] w = ((case x of