From a81f43ed91e15c9c57e65f04dd46f988cfb68f7b Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 2 Oct 2023 10:04:48 +0200 Subject: Ignore lambdabot Lambdabot also ignores yahb2; this is all to prevent accidental (or not so accidental) loops --- src/IRC.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/IRC.hs b/src/IRC.hs index 8a956d1..ca4e0d5 100644 --- a/src/IRC.hs +++ b/src/IRC.hs @@ -59,7 +59,8 @@ privmsgHandler :: (Text -> Maybe a) -> (a -> Text -> IO [Text]) -> EventHandler privmsgHandler commandDetect msgFun = EventHandler (\ev -> case ev ^. message of Privmsg _ (Right text) - | Just s <- commandDetect text -> Just (ev ^. source, text, s) + | sendingUser (ev ^. source) `notElem` map Just excludedNicks + , Just s <- commandDetect text -> Just (ev ^. source, text, s) _ -> Nothing) (\_ (src, text, s) -> do msgs <- liftIO $ msgFun s text @@ -71,6 +72,14 @@ privmsgHandler commandDetect msgFun = EventHandler forM_ msgs $ \msg -> send $ Privmsg target (Right msg)) +sendingUser :: Source a -> Maybe a +sendingUser (User n) = Just n +sendingUser (Channel _ n) = Just n +sendingUser (Server _) = Nothing + +excludedNicks :: [Text] +excludedNicks = [T.pack "lambdabot"] + -- stdoutLogger :: Origin -> ByteString -> IO () -- stdoutLogger origin x = do -- putStrLn $ unwords -- cgit v1.2.3-70-g09d2