diff options
Diffstat (limited to '.config/maildirproc/att.rc')
-rw-r--r-- | .config/maildirproc/att.rc | 101 |
1 files changed, 33 insertions, 68 deletions
diff --git a/.config/maildirproc/att.rc b/.config/maildirproc/att.rc index c94ac8d..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]. @@ -114,81 +130,30 @@ def handle_incoming_unknown(mail): return def my_filters(mail): - # Sort mail from GNU mailing lists + # Sort mail from various mailing lists # https://lists.gnu.org/mailman/options/bug-librejs/lukeshu@sbcglobal.net - #m = mail["List-Id"].matches("(.*<)?([^<]*)\.gnu\.org") - #if m: - # move_ham(mail,".software.gnu."+m.group(2)) - # return - - for list in [ 'bug-librejs', - 'bug-make', - 'help-grub', - 'help-make', - 'social', - 'social-discuss', - 'stow-devel', - 'bug-gnuzilla', - 'bug-gsrc' ]: - if ( - False - or mail["List-Id"].matches(list+"\.gnu\.org") - or mail["Subject"].contains('['+list+']') - ): - import pdb; pdb.set_trace() - move_ham(mail,".software.gnu."+list) - return - # Sort mail from non-GNU mailing lists # https://lists.nongnu.org/mailman/options/libreboot/lukeshu@sbcglobal.net - for list in [ 'libreboot', - 'libreboot-dev', - 'librefm-announce', - 'social-announce', - 'gnu-linux-libre' ]: - if ( - False - or mail["List-Id"].matches(list+"\.nongnu\.org") - or mail["Subject"].contains('['+list+']') - ): - import pdb; pdb.set_trace() - move_ham(mail,".software.nongnu."+list) - return - # Sort mail from Gnome mailing lists # https://mail.gnome.org/mailman/options/networkmanager-list/lukeshu@sbcglobal.net - for list in [ 'networkmanager-list' ]: - if mail["List-Id"].matches(list+"\.gnome\.org"): - move_ham(mail,".software.gnome."+list) + 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 Arch Linux mailing lists - for list in [ 'arch-projects', 'pacman-dev' ]: - if mail["List-Id"].matches(list+"\.archlinux\.org"): - move_ham(mail,".software.archlinux."+list) - return - # Sort mail from other mailing lists - 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 - # Sort mail from Parabola mailing lists - if mail["List-Id"].matches("maintenance\.lists\.parabola\.nu"): - move_ham(mail,".software.parabola.maintenance") - return - if mail["List-Id"].matches("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 + move_ham(mail,".software.parabola") + return # Sort mail from some social websites if mail["From"].matches("facebook(|mail)\.com"): |