X-Git-Url: https://git.martlubbers.net/?p=cloogle-irc.git;a=blobdiff_plain;f=cloogle.icl;h=b2c7bdfe66c0c5b346be0a04c575d8e6df952e55;hp=35b71c242e8ef43e8fdef8e5def6ce039d1cce43;hb=befcf2ab2ca4e80eebcbd839ce4a0375ae9a6012;hpb=1547e1cacf063d05c1ae686e6a1047792e13ef60 diff --git a/cloogle.icl b/cloogle.icl index 35b71c2..b2c7bdf 100644 --- a/cloogle.icl +++ b/cloogle.icl @@ -111,18 +111,23 @@ 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 == "!restart" = (Nothing, 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 @@ -153,7 +158,6 @@ Start w = bot ("irc.freenode.net", 6667) startup shutdown () process w realProcess ["query":xs] w = case xs of [] = (["query requires one or more arguments"], w) xs = appFst (split "\n") $ cloogle (join " " xs) w - realProcess ["restart"] w = abort "Restarted" realProcess ["restart":_] w = (["restart takes no arguments"], w) realProcess [c:_] w = ([join " " [ "Unknown cmd: ", c, ", type !help to get help"]], w)