summaryrefslogtreecommitdiff
path: root/.config/maildirproc/att.rc
diff options
context:
space:
mode:
authorLuke Shumaker <shumakl@purdue.edu>2015-02-06 15:17:51 -0500
committerLuke Shumaker <shumakl@purdue.edu>2015-02-06 15:17:51 -0500
commitdab097d5000c4697761b6985cb3512f7bce0147f (patch)
tree7b81b7826a1e23822955560f0f73dc09cda6c8e8 /.config/maildirproc/att.rc
parentf50b49ef26f5c692bda1f3f13cd38f9f4f395300 (diff)
parenta6f973687fb4a1a4558f74f7da595b6902a5dce0 (diff)
Merge remote-tracking branch 'origin/master' into purdue-cs/master
Conflicts: .config/X11/clientrc .config/bash/rc.d/emacs.sh .config/cron/make-config .config/emacs/custom.el .config/emacs/init.el .config/git/config .config/login.sh .config/selected_editor .local/bin/config-path
Diffstat (limited to '.config/maildirproc/att.rc')
-rw-r--r--.config/maildirproc/att.rc214
1 files changed, 120 insertions, 94 deletions
diff --git a/.config/maildirproc/att.rc b/.config/maildirproc/att.rc
index 381ce8f..6b31260 100644
--- a/.config/maildirproc/att.rc
+++ b/.config/maildirproc/att.rc
@@ -1,7 +1,9 @@
# -*- mode: python; indent-tabs-mode: t -*-
import os
+import os.path
import subprocess
+import datetime
processor.maildir_base = "~/Maildir"
processor.auto_reload_rcfile = True
@@ -24,6 +26,16 @@ def is_to_or_from_re(mail,address):
return (
mail["From"].matches(address)
or mail.target.matches(address))
+def move_ham(mail,folder):
+ y = datetime.datetime.now().year
+ folder = "FOLDERS.Ham."+str(y)+folder
+ dir = processor.maildir_base+"/"+folder
+ if not os.path.isfile(dir+"/maildirfolder"):
+ os.makedirs(dir+"/tmp", 0o777, True)
+ os.makedirs(dir+"/new", 0o777, True)
+ os.makedirs(dir+"/cur", 0o777, True)
+ open(dir+"/maildirfolder", 'a').close()
+ mail.move(folder)
def bogofilter_auto(mail):
p = subprocess.Popen(
@@ -37,28 +49,53 @@ def bogofilter_auto(mail):
"Error running bogofilter: Return code = {0!r}".format(
p.returncode))
return p.returncode
-
def bogofilter_ham(mail):
subprocess.call(["bogofilter", "-S", "-n", "-I", mail.path])
-
def bogofilter_spam(mail):
subprocess.call(["bogofilter", "-N", "-s", "-I", mail.path])
-def handle_incoming_spam_training(mail):
- bogofilter_spam(mail)
- mail.move(".Bulk Mail")
-
def handle_incoming_ham_training(mail):
bogofilter_ham(mail)
handle_incoming_ham(mail)
+def handle_incoming_spam_training(mail):
+ bogofilter_spam(mail)
+ mail.move("FOLDERS.Spam")
def handle_incoming_ham(mail):
my_filters(mail)
def handle_incoming_spam(mail):
- mail.move(".Bulk Mail")
+ mail.move("FOLDERS.Spam")
def handle_incoming_unknown(mail):
# Filter spam
+
+ # Whitelist
+ if (
+ False
+ or is_to_or_from(mail, "fsf.org")
+ or is_to_or_from(mail, "gnu.org")
+ or is_to_or_from(mail, "parabola.nu")
+ or is_to_or_from(mail, "parabolagnulinux.org")
+ or mail["From"] == "MAILER-DAEMON@yahoo.com"
+ or mail["From"].contains("@facebookmail.com>")
+ or mail["From"].contains("@gandi.net")
+ or mail["From"].contains("@goodwillindy.org>")
+ or mail["From"].contains("@lpi.org>")
+ or mail["From"].contains("@msdlt.k12.in.us>")
+ or mail["From"].contains("@parabola.nu")
+ or mail["From"].contains("@post.oreilly.com>")
+ or mail["From"].contains("@scouting.org>")
+ or mail["From"].contains("@wolframalpha.com>")
+ or mail["From"].contains("parabolagnulinux.org")
+ or mail["List-Id"].matches(".*\.(gnu|gnome|archlinux|parabolagnulinuxlibre)\.org")
+ or mail["List-Id"].matches(".*\.parabola\.nu")
+ or mail["Subject"].contains("[Dev]")
+ or mail["Subject"].contains("[Maintenance]")
+ or mail["Subject"].contains("[PATCH")
+ or mail["Subject"].contains("[systemd-devel]")
+ ):
+ handle_incoming_ham_training(mail)
+ return
spam = bogofilter_auto(mail)
if spam == 0:
@@ -68,10 +105,10 @@ def handle_incoming_unknown(mail):
handle_incoming_ham(mail)
return
elif spam == 2:
- # maybe spam
+ mail.move("FOLDERS.MysteryMeat")
return
else:
- mail.move(".Error")
+ mail.move("FOLDERS.BogoFail")
return
def my_filters(mail):
@@ -82,7 +119,7 @@ def my_filters(mail):
or mail["List-Id"].matches(list+"\.gnu\.org")
or mail["Subject"].contains('['+list+']')
):
- mail.move(".software."+list)
+ move_ham(mail,".software."+list)
return
# Sort mail from other software mailing lists
@@ -91,67 +128,54 @@ def my_filters(mail):
or mail["List-Id"].matches("social-discuss\.gnu\.org")
or mail["Subject"].contains("social-discuss")
):
- mail.move(".software.social")
+ move_ham(mail,".software.social")
return
if mail["List-Id"].matches("networkmanager-list\.gnome\.org"):
- mail.move(".software.networkmanager")
+ move_ham(mail,".software.networkmanager")
return
- if mail["List-Id"].matches("maintenance.lists.parabolagnulinux.org"):
- if mail["From"].contains("monit@"):
- if mail["Message-Id"].contains("@repo.parabolagnulinux.org"):
- if mail["Subject"].matches("^\[Maintenance\] monit alert -- (Execution|Connection) (succeeded|failed) sshd$"):
- mail.move(".software.parabola-maintenance.monit-repo.sshd")
- return
- mail.move(".software.parabola-maintenance.monit-repo")
- return
- if mail["Message-Id"].contains("@rshg054.dnsready.net"):
- mail.move(".software.parabola-maintenance.monit-rshg054")
- return
- if mail["Subject"].matches("Cron <.*@repo>"):
- mail.move(".software.parabola-maintenance.cron-repo")
- return
- if mail["Subject"].matches("Cron <.*@rshg054>"):
- mail.move(".software.parabola-maintenance.cron-rshg054")
- return
- mail.move(".software.parabola-maintenance")
+ if mail["List-Id"].matches("maintenance\.lists\.parabola(gnulinux\.org|\.nu)"):
+ move_ham(mail,".software.parabola.maintenance")
return
- if is_to_or_from(mail, "parabola.nu"):
- mail.move(".software.parabola-labs")
+ 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("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")
):
if mail["Subject"].contains("[Django]"):
- mail.move(".software.parabola-maintenance.django")
+ move_ham(mail,".software.parabola.maintenance.django")
+ return
+ else:
+ move_ham(mail,".software.parabola.dev")
return
- mail.move(".software.parabola-dev")
- return
if (mail["List-Id"].matches("pacman-dev.archlinux.org")):
- mail.move(".software.pacman-dev")
+ move_ham(mail,".software.pacman-dev")
return
- if (mail["List-Id"].matches("systemd-devel.lists.freedesktop.org")):
- mail.move(".software.systemd-devel")
+ 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):
- mail.move(".software")
+ move_ham(mail,".software")
return
# Sort mail from some social websites
if mail["From"].matches("facebook(|mail)\.com"):
- mail.move(".Social.Facebook")
+ move_ham(mail,".Social.Facebook")
return
if (
@@ -159,15 +183,24 @@ def my_filters(mail):
or mail["From"].matches("identi\.ca")
or mail["From"].matches("statusnet")
):
- mail.move(".Social.Identica")
+ move_ham(mail,".Social.Identica")
return
+ if (
+ False
+ or mail["From"].contains("@gandi.net")
+ or mail["From"].contains("@ramhost.us")
+ or mail["From"].contains("@startcom.org")
+ ):
+ move_ham(mail,".lukeshu-com")
+ return
+
if mail["From"].matches("twitter\.com"):
- mail.move(".Social.Twitter")
+ move_ham(mail,".Social.Twitter")
return
if mail["From"].matches("@xkcd\.com"):
- mail.move(".Social.xkcd")
+ move_ham(mail,".Social.xkcd")
return
# Sort mail related to Troop 276
@@ -191,30 +224,24 @@ def my_filters(mail):
or is_to_or_from(mail,"mytroop.us")
or is_to_or_from(mail,"crossroadsbsa.org")
):
- mail.move(".Troop276")
+ move_ham(mail,".BoyScouts")
return
# Sort mail from misc people
- if mail["From"].matches("margieshu@sbcglobal\.net"):
- mail.move(".misc.Mom")
+ if (
+ False
+ or is_to_or_from(mail,"margieshu@sbcglobal.net")
+ or is_to_or_from(mail,"3174451635@mms.att.net")
+ ):
+ move_ham(mail,".misc.Mom")
return
for address in [
- "justicejade10@aol.com",
- "parsonsjade@aol.com",
- "parsonstjade@gmail.com",
- "jadparso@umail.iu.edu",
- ]:
- if is_to_or_from(mail,address):
- mail.move(".misc.Jade")
- return
-
- for address in [
"nintendo.com",
"nintendo-news.com",
]:
if mail["From"].contains(address):
- mail.move(".misc.Nintendo")
+ move_ham(mail,".misc.Nintendo")
return
for address in [
@@ -223,7 +250,7 @@ def my_filters(mail):
"CompTIA",
]:
if mail["From"].contains(address):
- mail.move(".misc.CompTIA")
+ move_ham(mail,".misc.CompTIA")
return
# Sort mail from FRC people
@@ -248,37 +275,38 @@ def my_filters(mail):
"william.walk@gmail.com",
]:
if is_to_or_from(mail,address):
- mail.move(".School.Robotics")
+ move_ham(mail,".School.Robotics")
return
for subject_re in [
"robotics",
- "1024",
+ "\b1024\b",
+ "\b4272\b",
"kil-?a-?bytes",
]:
if mail["Subject"].matches(subject_re):
- mail.move(".School.Robotics")
+ move_ham(mail,".School.Robotics")
return
# Sort mail from software people
for address in [
"@archlinux.org",
+ "@canonical.org",
+ "@cnuk.org",
+ "@eff.org",
+ "@foocorp.net",
"@fsf.org",
"@github.com",
- "canonical.org",
- "cnuk.org",
- "eff.org",
- "esr@thyrsus.com",
- "foocorp.net",
- "gitorious.org",
- "gnome.org",
- "gnu.org",
- "ietf.org",
- "kde.org",
- "sourceforge.com",
+ "@gitorious.org",
+ "@gnome.org",
+ "@gnu.org",
+ "@ietf.org",
+ "@kde.org",
+ "@sourceforge.com",
+ "@thyrsus.com",
"trustees@core3.amsl.com",
]:
if is_to_or_from(mail,address):
- mail.move(".software")
+ move_ham(mail,".software")
return
@@ -288,16 +316,16 @@ def my_filters(mail):
or is_to_or_from(mail, "@lnnorthstar.org")
or is_to_or_from(mail, "lnnorthstar.org@tigertech.net")
):
- mail.move(".School.Newspaper")
+ move_ham(mail,".School.Newspaper")
return
# Sort mail from various employers/people who pay me
if is_to_or_from(mail, "@precisepath.com"):
- mail.move(".Work.PrecisePath")
+ move_ham(mail,".Work.PrecisePath")
return
if is_to_or_from(mail,"susyphil@aol.com"):
- mail.move(".Work.PMCH")
+ move_ham(mail,".Work.PMCH")
for address in [
"d.farrar@comcast.net",
@@ -305,7 +333,7 @@ def my_filters(mail):
"@vmware.com",
]:
if is_to_or_from(mail,address):
- mail.move(".Work.FAST")
+ move_ham(mail,".Work.FAST")
return
# Sort misc newsletters
@@ -319,12 +347,13 @@ def my_filters(mail):
or mail["From"].contains("info@demandprogress.org")
or (mail["From"].contains("@sparkfun.com") and mail["Message-Id"].contains("rsgsv.net"))
):
- mail.move(".misc.Newsletters")
+ move_ham(mail,".misc.Newsletters")
return
if (
False
or mail["From"].contains("@msdlt.k12.in.us")
+ or mail["From"].contains("ltschoolfoundation@gmail.com")
or mail["From"].contains("naviance.com")
or is_to_or_from(mail,"ibwhite@comcast.net")
or mail["Subject"].contains("IOA")
@@ -334,7 +363,7 @@ def my_filters(mail):
or mail["Subject"].contains("NHS")
or mail["Subject"].contains("National Honor Society")
):
- mail.move(".School")
+ move_ham(mail,".School")
return
# from college stuff
@@ -343,50 +372,47 @@ def my_filters(mail):
or mail["Subject"].contains("NYLF") # National Youth Leadership Conference
or mail["Subject"].contains("NSHSS")
):
- mail.move(".College.Societies")
+ move_ham(mail,".College.Societies")
return
if (
False
- #or mail["From"].contains(".edu")
or mail["From"].contains("admissions@")
- #or mail["From"].contains("college")
- #or mail["From"].contains("university")
or mail["Subject"].contains("college")
# now we get to the BS
or mail["From"].contains("@dreamitdoitindiana.com")
or mail["From"].contains("@indianatechinfo.org")
):
- mail.move(".College")
+ move_ham(mail,".College")
return
if mail["From"].contains("@projectwonderful.com"):
- mail.move(".ProjectWonderful")
+ move_ham(mail,".misc.ProjectWonderful")
return
if (
False
or mail["From"].matches("@localhost")
or mail["From"].matches("@[^,>]*\.local")
- or mail["From"].matches("@[^,>]*\.lukeshu\.ath\.cx")
+ or mail["From"].matches("@[^,>]*\.lan")
or mail["To"].matches("luke@")
):
- mail.move(".LocalSystems")
+ move_ham(mail,".LocalSystems")
return
if (
False
or mail["Subject"].contains("password")
or mail["Subject"].contains("account")
):
- mail.move(".misc.accounts")
+ move_ham(mail,".misc.accounts")
return
- mail.move(".Ham")
+ move_ham(mail,"")
handle_mapping = {
- ".": handle_incoming_unknown,
- ".spam-training": handle_incoming_spam_training,
- ".ham-training": handle_incoming_ham_training,
- #".Ham": handle_incoming_ham,
+ "Inbox": handle_incoming_unknown,
+ "Bulk Mail": handle_incoming_unknown,
+ "FOLDERS.Spam.training": handle_incoming_spam_training,
+ "FOLDERS.Ham.training": handle_incoming_ham_training,
}
processor.maildirs = handle_mapping.keys()
for mail in processor: