#!/bin/csh -f # nomagats # ----------------------------------------------------------------------------- # C shell script to merge the specified mailing lists, echoing a union of # all lines from all lists, but subtracting those lines that exist in the # MAGAts and potential MAGAts lists, and those who've explicitly asked to # get no political email. # ----------------------------------------------------------------------------- # Usage: See Usage section below or run with -h or --help to see usage. # Assumptions: # Effects: # Notes: # Implementation Notes: # Portability Issues: # Revision History: # $Log$ # ----------------------------------------------------------------------------- # Collect command line options set option_political = "false" while ($#argv > 0) if ("$1:q" == "-h" || "$1:q" == "--help") then echo "Usage: $0:t [options] mailing_list_file..." echo "Options:" echo " -h = Show this help info" echo " --help = Show this help info" echo " -p = Political email, strip more aggressively" echo " --political = Political email, strip more aggressively" echo " --help = Show this help info" exit 1 else if ("$1" == "-p" || "$1" == "--political") then shift set option_political = "true" else if ("-" == "`echo $1:q | cut -c 1`") then echo "Error: Invalid option: $1:q" $0:t --help exit 1 else # Not a recognized option. Assume it's the first parameter break endif end set timestamp = `date "+%Y_%m_%d__%H_%M_%S"` set tempfile1 = "/tmp/$0:t_$$_file1_$timestamp" set tempfile2 = "/tmp/$0:t_$$_file2_$timestamp" set unionfile = "/tmp/$0:t_$$_union_$timestamp" set subtractfile = "/tmp/$0:t_$$_subtract_$timestamp" set outfile = "/tmp/$0:t_$$_out_$timestamp" cd ~/fred/Mozilla/TBird/lists # Build merged mailing list touch $tempfile1:q while ($#argv > 0) set listname = $1:q shift if (! -e $listname:q) then set listname = "${listname}.lis" endif if (! -e $listname:q) then beep "Error: File $listname does not exist." rm -f $tempfile1:q rm -f $tempfile2:q exit 1 endif union -i $listname:q $tempfile1:q > $tempfile2:q mv $tempfile2:q $tempfile1:q end mv $tempfile1:q $unionfile:q # Build merged subtract list # Strip out addresses from these lists for all mailings. No need to send # ANY email to MAGAts. My signature file may annoy them, and I don't # really want to support them in any way anyhow. # Also strip out those who accepted HHNHH signs but explicitly asked to # NOT get any mass mailings from me. # # Fri 4/25/2025: # Decided to NOT always strip out VoteNoSpam list. Was stripping too # many people who want less political email because they're overwhelmed, # or not US citizens or whatever, but are still big fans of my tips. # Examples: Thor, Dave Bartlett, Paul Burton, Dave Brophy, Tommy Brophy, # Stephen Lafredo, Dave Osborne, John Pierson, etc. # Decided to also NOT strip out TrumpNo_NoSpam list. Was still stripping # too many people like Thor and Dave Bartlett. # Manually reviewed the TrumpNo_NoSpam list. Decided it was generally OK # to send stuff to them, as long as it's not too political. # BCC: "Anderson, Rhonda -- nofinance, Common Cause EP 2018 volunteer" # - Not on any lists anyhow, except entire address book # BCC: "Bannan, Chris -- nospam" # - Not on any lists anyhow, except entire address book # BCC: "Bartlett, Dave" # - Explicitly DO want to send most emails to him. # When sending political stuff, I should always use the --political option. # BCC: "Collard, Thor" # - Explicitly DO want to send most emails to him. # When sending political stuff, I should always use the --political option. # BCC: "Gardberg, Madeleine -- nospam, EW3 pollworker" # - Not on any lists anyhow, except entire address book # BCC: "Holmes, Bill -- nospam" # - Not on any lists anyhow, except entire address book # BCC: "Jacquette, Frank -- nofinance" # - Explicitly DO want to send most emails to him. # When sending political stuff, I should always use the --political option. # BCC: "Lewis, Andrew" # - Not on any lists anyhow, except entire address book # BCC: "Pioch, Dave and Jennifer -- HHNHH sign" # - Not on any lists anyhow, except entire address book and HHNHH # When sending to HHNHH, I should always use the --political option. # BCC: "Strebi, Jodi -- HHNHH sign" # - She's on HHNHH and LocalFriends, but also TrumpNo_NoSpam. # When sending political stuff, I should always use the --political option. # BCC: "Tao, David" # - He's on a bunch of lists, but willing to tolerate Trump. # - Re-read past emails and moved him from TrumpNo_NoSpam to TrumpDontCare # since he doesn't seem to thunk Trump is particularly bad. # He'll continue to always be filtered. # BCC: "Ward, Dave" # - Not on any lists anyhow, except entire address book and SPC # - Re-read past emails and moved him from TrumpNo_NoSpam to TrumpDontCare # since he doesn't seem to thunk Trump is particularly bad. # He'll continue to always be filtered. set listnames = (TrumpYes_NoSpam \ TrumpYes \ TrumpDontCare \ HHNHH_nospam \ ) # Fri 4/25/2025: # For political emails, like protest rallies and general anti-Trump info # that I might be inclined to send to large lists like LocalFriends, also # strip out VoteNoSpam because they explicitly asked to NOT get any voting # info or other political email. # And strip out TrumpNo_NoSpam because, despite being anti-Trump, they # explicitly asked to NOT get any political email. if ("$option_political" == "true") then set listnames = ($listnames \ VoteNoSpam \ TrumpNo_NoSpam \ ) endif touch $tempfile1:q foreach listname ($listnames) if (! -e $listname:q) then set listname = "${listname}.lis" endif if (! -e $listname:q) then beep "Error: File $listname does not exist." rm -f $tempfile1:q rm -f $tempfile2:q rm -f $unionfile:q exit 1 endif union -i $listname:q $tempfile1:q > $tempfile2:q mv $tempfile2:q $tempfile1:q end mv $tempfile1:q $subtractfile:q # Subtract from the merged list, stripping off "BCC: " prefixes subtract -i $unionfile:q $subtractfile:q | sed -e "s/^BCC: //g" > $outfile:q # Filter out all flagged addresses: mv $outfile:q $tempfile1:q foreach flag ( \ deceased \ bouncing \ ) grep -v "$flag" $tempfile1:q > $tempfile2:q mv $tempfile2:q $tempfile1:q end mv $tempfile1:q $outfile:q # Emit the resulting lines cat $outfile:q # Cleanup rm -f $tempfile1:q rm -f $tempfile2:q rm -f $unionfile:q rm -f $subtractfile:q rm -f $outfile:q