filterMsg :: (MonadIO m, Monad m)
              => IRCSettings
              -> Pipe Message Message m r
filterMsg (IRCSettings{..}) = loop
  where loop = do
          msg <- await
          case msgCommand msg of
            PrivMsgCmd targets txt -> do
              let me = S.insert nick channels
              if (trigger `BS.isPrefixOf` txt)
                 && (not . S.null $ me `S.intersection` targets)
               then yield msg >> loop
               else loop
            _ -> loop

-- | Proxy that responds to PING queries
filterMsg :: (MonadIO m, Monad m)
              => IRCSettings
              -> Pipe Message Message m r
filterMsg (IRCSettings{..}) = loop
  where loop = do
          msg <- await
          case msgCommand msg of
            PrivMsgCmd targets txt -> do
              let me = S.insert nick channels
              if (trigger `BS.isPrefixOf` txt)
                 && (not . S.null $ me `S.intersection` targets)
               then yield msg >> loop
               else loop
            _ -> loop

-- | Proxy that responds to PING queries
filterMsg (IRCSettings{..}) = loop
  where loop = do
          msg <- await
          case msgCommand msg of
            PrivMsgCmd targets txt -> do
              let me = S.insert nick channels
              if (trigger `BS.isPrefixOf` txt)
                 && (not . S.null $ me `S.intersection` targets)
               then yield msg >> loop
               else loop
            _ -> loop

-- | Proxy that responds to PING queries