I have just completed a new announcement list script.
I find that this is more complete and flexible than the current ones which I could find on the net. Also, unlike all the other scripts, this doesn't require bash (only sh), so it should be more cross platform, and save people from having to install bash on systems which don't have it on a default install.
Thanks Patrick for steering me on the right path earlier for setting the moderation bit for a user.
Feel free to use it for whatever purpose if you wish to do so, also, you can link to it at
http://www.netera.ca/mailinglists/MakeAnnounce.sh http://www.netera.ca/mailinglists/changemod.py -- Matthew Clarkson
from Mailman import mm_cfg from Mailman.Errors import NotAMemberError def setMemberModeratedFlag (mlist, addr, mod): mlist.setMemberOption (addr, mm_cfg.Moderate, mod) mlist.Save()
#!/bin/sh #----------------------------------------------------------------------------- # # Mailman Announce Script # Apr 26 2006 - Matthew Clarkson (matt _at_ netera (dot) ca) # # This script will create an announce list out of specified mailing lists # I have used two other scripts as a basis for this one, however, I find # that this is much more flexible, and easier to use after set up. # This script also uses sh, so you don't have to rely on a computer # to have bash, unlike the other scripts, which makes it a bit friendlier # to cross platform setups # # The reference scripts that I used are found at # http://mail.python.org/pipermail/mailman-users/2005-February/042392.html # http://mail.python.org/pipermail/mailman-users/2005-February/042392.html # # This script requires one other file to operate # changemod.py, place this file in ~mailman/bin # # In order to operate, the list must be created first, with appropriate # settings, I would recommend the following be selected # # /admin/netera-announce-l/general # send_reminders -> No # send_welcome_msg -> No # send_goodbye_msg -> No # /admin/<listname>/privacy/sender # default_member_moderation -> Yes # member_moderation_action -> ( Reject | Discard ) # generic_nonmember_action -> Discard # # This script uses the following files (I will use announce-l as my list) # # announce-l - list of mailing lists in mailman # announce-l.extra - list of additional email address' # announce-l.allow - list of email address' of people who can post # the list # # The files must have the same name as the list itself, all files must # be plaintext # #----------------------------------------------------------------------------- # General Usage message, it exits right after this is called usage() { echo 1>&2 "usage: ./MakeAnnounce <filename>" exit 127 } # We must have one, and only 1 argument for this script, other wise print # the usage mssage to the user, and exit if [ $# -ne 1 ]; then usage fi # We must get the filename directly, since we want the list name, and not # a name like /path/to/announce-l filename=`basename $1` # Make sure that there is a corresponding list for the filename, if not, print # usage message and exit EXISTS="`~mailman/bin/list_lists | grep -i $filename`" if [ -z "$EXISTS" ]; then usage fi # Loop through the main file, collecting all address' from all the lists in # the main file, and then adding them to /tmp/<listname>.tmp while read -r current_line do # to verify that the list exists (using bin/list_lists) EXISTS="`~mailman/bin/list_lists | grep -i $current_line | \ awk '{print $1 }'`" # if the list does not exist, print an error and continue on with the # next line if [ -z "$EXISTS" ]; then printf "ERROR: %s does not exist\n" "$current_line" else # add every address in the current list to the announce file printf "Adding %s to list\n" "$current_line" `~mailman/bin/list_members $current_line >> \ /tmp/$filename.tmp` fi done < $1 # if the .extra file exists, then add every address in this file to the # announce file if [ -f "$1.extra" ]; then while read -r current_line do `echo $current_line >> /tmp/$filename.tmp` done < $1.extra fi # sort the list alphabetically and remove duplicates. sync_members will remove # all duplicates, so the '-u' can be removed, although, it's easier to go # through the text file when there are no dupes, if you ever want to do that. cat /tmp/$filename.tmp | sort -u > /tmp/$filename.tmp.final # add all address' in the .tmp.final file. This also removes all address' from # the list which are not in the .tmp.final file, output goes to /dev/null ~mailman/bin/sync_members -f /tmp/$filename.tmp.final $filename > /dev/null # now we set the moderation bit to every user that is in the .allow file if [ -f "$1.allow" ]; then while read -r current_line do # see if user exists in the announce .tmp.final file EXISTS="`~mailman/bin/list_members $filename | \ grep -i $current_line`" # if the user is not in this file, then display an error message if [ -z "$EXISTS" ]; then printf "ERROR: %s is not a member\n" "$current_line" # if the user is in the file, then unset their moderator bit else `~mailman/bin/withlist -q -l -r \ changemod.setMemberModeratedFlag \ $filename $current_line ''` fi done < $1.allow fi # remove our working files rm /tmp/$filename.tmp rm /tmp/$filename.tmp.final
------------------------------------------------------ Mailman-Users mailing list Mailman-Users@python.org http://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://www.python.org/cgi-bin/faqw-mm.py Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: http://mail.python.org/mailman/options/mailman-users/archive%40jab.org Security Policy: http://www.python.org/cgi-bin/faqw-mm.py?req=show&file=faq01.027.htp