diff options
author | Tom Smeding <tom@tomsmeding.com> | 2023-10-02 10:04:48 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2023-10-02 10:04:48 +0200 |
commit | a81f43ed91e15c9c57e65f04dd46f988cfb68f7b (patch) | |
tree | 967956416199fc3d2771cd0b18bce73e5b103c7b | |
parent | e7a3680052a9b3ef206af4cd934b6a0d61ffb7ad (diff) |
Ignore lambdabot
Lambdabot also ignores yahb2; this is all to prevent accidental (or not
so accidental) loops
-rw-r--r-- | src/IRC.hs | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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 |