diff options
Diffstat (limited to '.config/maildirproc')
-rw-r--r-- | .config/maildirproc/att.rc | 159 | ||||
-rw-r--r-- | .config/maildirproc/purdue.rc | 16 |
2 files changed, 83 insertions, 92 deletions
diff --git a/.config/maildirproc/att.rc b/.config/maildirproc/att.rc index 7ee5f42..98ef8ae 100644 --- a/.config/maildirproc/att.rc +++ b/.config/maildirproc/att.rc @@ -4,10 +4,26 @@ import os import os.path import subprocess import datetime +import re processor.maildir_base = "~/Maildir" processor.auto_reload_rcfile = True +def mailman_domain(mail, domain): + """ + Return a string that is the list-name for a mailman domain + """ + m = mail["List-Id"].matches("(.*<)?([^<]*)\."+re.escape(domain)) + if m: + if mail["Subject"].contains("["+m.group(2)+"]"): + return m.group(2) + for hdr in [ 'To', 'Cc', 'From' ]: + m = mail[hdr].matches("(\w*)@"+re.escape(domain)) + if m: + if mail["Subject"].contains("["+m.group(1)+"]"): + return m.group(2) + return None + def is_to_or_from(mail,address): """ Return true if [mail] is to or from an address that contains [address]. @@ -89,7 +105,7 @@ def handle_incoming_unknown(mail): or mail["From"].contains("@wolframalpha.com>") or mail["From"].contains("margieshu@sbcglobal.net") or mail["From"].contains("parabolagnulinux.org") - or mail["List-Id"].matches(".*\.(gnu|gnome|archlinux|parabolagnulinuxlibre)\.org") + or mail["List-Id"].matches(".*\.(gnu|gnome|archlinux|parabolagnulinuxlibre|fedorahosted)\.org") or mail["List-Id"].matches(".*\.parabola\.nu") or mail["Subject"].contains("[Dev]") or mail["Subject"].contains("[Maintenance]") @@ -114,66 +130,30 @@ def handle_incoming_unknown(mail): return def my_filters(mail): - # Sort mail from GNU mailing lists - for list in [ 'bug-gsrc', 'bug-make', 'help-make', 'social', 'help-grub', 'bug-gnuzilla', 'bug-librejs' ]: - if ( - False - or mail["List-Id"].matches(list+"\.gnu\.org") - or mail["Subject"].contains('['+list+']') - ): - move_ham(mail,".software."+list) + # Sort mail from various mailing lists + # https://lists.gnu.org/mailman/options/bug-librejs/lukeshu@sbcglobal.net + # https://lists.nongnu.org/mailman/options/libreboot/lukeshu@sbcglobal.net + # https://mail.gnome.org/mailman/options/networkmanager-list/lukeshu@sbcglobal.net + for pair in [ [ 'gnu.org', 'gnu' ], + [ 'nongnu.org', 'nongnu' ], + [ 'gnome.org', 'gnome' ], + [ 'archlinux.org', 'archlinux' ], + [ 'lists.freedesktop.org', 'freedesktop' ], + [ 'lists.fedorahosted.org', 'fedorahosted' ], + [ 'lists.parabola.nu', 'parabola' ], + [ 'parabola.nu', 'parabola' ] ]: + list = mailman_domain(mail, pair[0]) + if list: + move_ham(mail,".software."+pair[1]+"."+list) return - - # Sort mail from other software mailing lists if ( False - or mail["List-Id"].matches("social-discuss\.gnu\.org") - or mail["Subject"].contains("social-discuss") - ): - move_ham(mail,".software.social") - return - - if mail["List-Id"].matches("networkmanager-list\.gnome\.org"): - move_ham(mail,".software.networkmanager") - return - - if mail["List-Id"].matches("maintenance\.lists\.parabola(gnulinux\.org|\.nu)"): - move_ham(mail,".software.parabola.maintenance") - return - - if is_to_or_from(mail, "labs@parabola.nu"): - move_ham(mail,".software.parabola.labs") - return - - if ( - False - or mail["List-Id"].matches("parabolagnulinux\.org") - or mail["List-Id"].matches("parabola\.nu") - or is_to_or_from(mail, "parabolagnulinux.org") - or is_to_or_from(mail, "kiwwwi.com.ar") - or is_to_or_from(mail, "parabola.nu") + or is_to_or_from(mail, "parabolagnulinux.org") + or is_to_or_from(mail, "parabola.nu") + or is_to_or_from(mail, "kiwwwi.com.ar") ): - if mail["Subject"].contains("[Django]"): - move_ham(mail,".software.parabola.maintenance.django") - return - else: - move_ham(mail,".software.parabola.dev") - return - - if (mail["List-Id"].matches("pacman-dev.archlinux.org")): - move_ham(mail,".software.pacman-dev") + move_ham(mail,".software.parabola") return - - if (mail["List-Id"].matches("systemd-devel.lists.freedesktop.org") or is_to_or_from(mail, "systemd-devel@lists.freedesktop.org")): - move_ham(mail,".software.systemd-devel") - return - - for subject_re in [ - "\[Stow-[^\]]*\].*", - ]: - if mail["Subject"].matches(subject_re): - move_ham(mail,".software") - return # Sort mail from some social websites if mail["From"].matches("facebook(|mail)\.com"): @@ -256,12 +236,27 @@ def my_filters(mail): return # Sort mail from FRC people + # Generic + for address in [ "@ni.com", "@usfirst.org" ]: + if is_to_or_from(mail,address): + move_ham(mail,".FRC") + return + # FRC 829 + for address in [ + "wcxctrack829@aim.com", # Pat + "william.walk@gmail.com", + ]: + if is_to_or_from(mail,address): + move_ham(mail,".FRC.829") + return + if mail["Subject"].matches("\b829\b"): + move_hame(mail,".FRC.829") + return + # FRC 1024 for address in [ - "@ni.com", - "@usfirst.org", "BBonahoom@stanleyworks.com", - "allison.m.babcock@gmail.com", "bryanbonahoom@gmail.com", + "allison.m.babcock@gmail.com", "cdewalt3@yahoo.com", "dave.nelson@ecolab.com", "dickaustin190@yahoo.com", @@ -273,24 +268,23 @@ def my_filters(mail): "silioso@gmail.com", "skiplittell@comcast.net", "tswilson4801@att.net", - "wcxctrack829@aim.com", # Pat - "william.walk@gmail.com", ]: if is_to_or_from(mail,address): - move_ham(mail,".School.Robotics") + move_ham(mail,".FRC.1024") return - for subject_re in [ - "robotics", - "\b1024\b", - "\b4272\b", - "kil-?a-?bytes", - ]: + for subject_re in [ "\b1024\b", "kil-?a-?bytes" ]: if mail["Subject"].matches(subject_re): - move_ham(mail,".School.Robotics") + move_ham(mail,".FRC.1024") return + # FRC 4272 + if mail["Subject"].matches("\b4272\b"): + move_hame(mail,".FRC.4272") + return + # Catch BS things because of CS classes before the general + # software filters if mail["Subject"].contains("[Quizroom]"): - move_ham(mail,".School.CS408") + mail.delete() return # Sort mail from software people @@ -298,6 +292,8 @@ def my_filters(mail): "@archlinux.org", "@canonical.org", "@cnuk.org", + "@core3.amsl.com", + "@defectivebydesign.org", "@eff.org", "@foocorp.net", "@fsf.org", @@ -310,39 +306,20 @@ def my_filters(mail): "@nongnu.org", "@sourceforge.com", "@thyrsus.com", - "trustees@core3.amsl.com", ]: if is_to_or_from(mail,address): move_ham(mail,".software") return - # Sort mail from the school newspaper if ( False or is_to_or_from(mail, "@lnnorthstar.org") or is_to_or_from(mail, "lnnorthstar.org@tigertech.net") ): - move_ham(mail,".School.Newspaper") - return - - # Sort mail from various employers/people who pay me - if is_to_or_from(mail, "@precisepath.com"): - move_ham(mail,".Work.PrecisePath") + move_ham(mail,".HighSchool.Newspaper") return - if is_to_or_from(mail,"susyphil@aol.com"): - move_ham(mail,".Work.PMCH") - - for address in [ - "d.farrar@comcast.net", - "dfarrar@avacoustics.net", - "@vmware.com", - ]: - if is_to_or_from(mail,address): - move_ham(mail,".Work.FAST") - return - # Sort misc newsletters if ( False @@ -370,7 +347,7 @@ def my_filters(mail): or mail["Subject"].contains("NHS") or mail["Subject"].contains("National Honor Society") ): - move_ham(mail,".School") + move_ham(mail,".HighSchool") return # from college stuff diff --git a/.config/maildirproc/purdue.rc b/.config/maildirproc/purdue.rc index d1505f9..f086eee 100644 --- a/.config/maildirproc/purdue.rc +++ b/.config/maildirproc/purdue.rc @@ -103,7 +103,12 @@ def my_filters(mail): mail.move("INBOX.work.2013.Comcast") return - if is_to_or_from(mail,"@Cartus.com"): + if ( + False + or is_to_or_from(mail,"@qualcomm.com") + or is_to_or_from(mail,"@Cartus.com") + or is_to_or_from(mail,"@quicinc.com") + ): mail.move("INBOX.work.2015.qualcomm") return @@ -268,6 +273,9 @@ def my_filters(mail): return # CS448 (Databases) if piazza_topic(mail, "CS 44800"): + mail.move("INBOX.classes.2015-1.CS448.Piazza") + return + if mail["Subject"].matches("CS *448"): mail.move("INBOX.classes.2015-1.CS448") return # ME297 (FRC) @@ -278,6 +286,12 @@ def my_filters(mail): mail.move("INBOX.classes.2015-1.ME297") return # SOC324 (Criminology) + if mail["Subject"].contains("spring-2015-soc-32400"): + mail.move("INBOX.classes.2015-1.SOC324") + return + + # Everything else ##################################################### + mail.move("INBOX.ham"); handle_mapping = { "INBOX": my_filters, |