aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2023-10-02 10:04:48 +0200
committerTom Smeding <tom@tomsmeding.com>2023-10-02 10:04:48 +0200
commita81f43ed91e15c9c57e65f04dd46f988cfb68f7b (patch)
tree967956416199fc3d2771cd0b18bce73e5b103c7b
parente7a3680052a9b3ef206af4cd934b6a0d61ffb7ad (diff)
Ignore lambdabot
Lambdabot also ignores yahb2; this is all to prevent accidental (or not so accidental) loops
-rw-r--r--src/IRC.hs11
1 files changed, 10 insertions, 1 deletions
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