Created
August 23, 2011 12:13
-
-
Save Tarrasch/1164962 to your computer and use it in GitHub Desktop.
Module for checking users in mailman list group
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Mailman where | |
import System.Process (readProcessWithExitCode) | |
import System.Exit (ExitCode(..)) | |
import Data.List | |
type MailingList = String | |
-- Before using this module: | |
-- Make sure you have `list_members` command available, and that you don't | |
-- get any permission denied errors when using it with any user. | |
-- > listsToCids "[email protected]\[email protected]\[email protected]" | |
-- ["rarash"] | |
listsToCids :: String -> [String] | |
listsToCids = map (takeWhile (/='@')) | |
. filter (isSuffixOf "@student.chalmers.se") | |
. lines | |
getMembers :: MailingList -> IO(Either String [String]) | |
getMembers maillist = do | |
(exitCode, sout, serr) <- readProcessWithExitCode "list_members" [maillist] "" | |
case exitCode of | |
ExitSuccess -> return $ Right $ listsToCids sout | |
_ -> return $ Left $ show exitCode ++ ":\n\n" ++ serr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment